作者:手机用户2702932962_848 | 来源:互联网 | 2017-05-14 02:44
乱码原因:
源码文件的编码格式为utf-8,但是window的本地默认编码是gbk,所以在控制台直接打印utf-8的字符串当然是乱码了!
解决方法:
1、print mystr.decode('utf-8').encode('gbk')
2、比较通用的方法:
代码如下:
import sys
type = sys.getfilesystemencoding()
print mystr.decode('utf-8').encode(type)