Convert GBK to utf8 string in python

前端 未结 5 1819
面向向阳花
面向向阳花 2021-01-07 04:16

I have a string.

s = u\"

        
5条回答
  •  自闭症患者
    2021-01-07 04:28

    in python2, try this to convert your unicode string:

    >>> s.encode('latin-1').decode('gbk')
    u""
    

    then you can encode to utf-8 as you wish.

    >>> s.encode('latin-1').decode('gbk').encode('utf-8')
    ""
    

提交回复
热议问题