PyCharm控制台显示unicode乱码(python程序)

控制台显示unicode乱码
在这里插入图片描述

解决方法:

把 print(segs_1)
改成
replace = str(segs_1).replace(‘u’’, ‘’’)
print(replace.decode(“unicode-escape”))
在这里插入图片描述

同时增加下面代码:

windows下的字符串str默认编码是ascii,而python编码是utf8
import sys
reload(sys)
sys.setdefaultencoding(‘utf8’)

猜你喜欢

转载自blog.csdn.net/lhxsir/article/details/83276544