python 2.7 安装目录修改mimetypes.py文件增加如下内容即可。
import os
import sys
#the following two line solve the "python ez_setup.py" install error
reload(sys)
sys.setdefaultencoding('gb18030')
#end
import posixpath
import urllib
try:
import _winreg
except ImportError:
参考下面的文章:
http://www.cppblog.com/lovebeyond/archive/2011/11/07/159754.html
解决UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 108: ordinal not in range(128)
混淆了 python 2 里边的 str 和 unicode 数据类型。0.
你需要的是让编码用实际编码而不是 ascii
1.
对需要 str->unicode 的代码,可以在前边写上
import sys
reload(sys)
sys.setdefaultencoding('utf8')
把 str 编码由 ascii 改为 utf8 (或 gb18030)
2.
python3 区分了 unicode str 和 byte arrary,并且默认编码不再是 ascii