python终极解决UnicodeEncodeError

python环境下没有设置defaultEncoding的场合,通常会报错UnicodeEncodeError。

我机器下的python安装在/usr/lib/python2.7
在该路径下新建sitecustomize.py

import sys
sys.setdefaultencoding('utf-8')


ok了

猜你喜欢

转载自xushans.iteye.com/blog/2279117