How do I convert a unicode to a string at the Python level?

后端 未结 7 1318
刺人心
刺人心 2020-12-09 17:56

The following unicode and string can exist on their own if defined explicitly:

>>> value_str=\'Andr\\xc3\\xa9\'
>>> value_uni=u\'Andr\\xc3\         


        
7条回答
  •  时光取名叫无心
    2020-12-09 18:25

    value_uni.encode('utf8') or whatever encoding you need.

    See http://docs.python.org/library/stdtypes.html#str.encode

提交回复
热议问题