Decode string with hex characters in python 2

前端 未结 5 1649
攒了一身酷
攒了一身酷 2021-01-13 21:38

I have a hex string and i want to convert it utf8 to insert mysql. (my database is utf8)

hex_string = \'kitap ara\\xfet\\xfdrmas\\xfd\'
...
result = \'kitap          


        
5条回答
  •  既然无缘
    2021-01-13 21:57

    Try(Python 3.x):

    import codecs
    codecs.decode("707974686f6e2d666f72756d2e696f", "hex").decode('utf-8')
    

    From here.

提交回复
热议问题