python 字符乱码问题

网上看到一篇对python乱码分析的文章:传送门

1.python 中文乱码

# encoding:utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf8')


2.python 字符乱码(重新编码)

s = u'\xb3\xc2\xbd\xa8\xc3\xf4'

s.encode('unicode_escape').decode('string_escape')

或者

s.encode('raw_unicode_escape')

猜你喜欢

转载自blog.csdn.net/weixin_40902527/article/details/86668121