Python cmd 中文显示乱码

方法一:

# -*- coding:utf-8 -*-

content = "我是中文"

content_unicode = content.decode("utf-8")

content_gbk = content_unicode.encode("gbk") print content_gbk

 

方法二:

先引入import sys

再加一句:type=sys.getfilesystemencoding()

然后在输出乱码的数据的时候在后面加上.decode('utf-8').encode(type)

比如输入ss乱码

就写成print ss.decode('utf-8').encode(type)即可

原文地址:https://www.cnblogs.com/njuptlwh/p/7562497.html