linux 下:

python安装目录:/etc/python2.x/sitecustomize.py

import sys
reload (sys)
sys.setdefaultencoding( 'utf-8' )
try :
   import apport_python_hook
except ImportError:
   pass
else :
   apport_python_hook.install()


windows 下:

可以在Python安装目录下的Lib/site-packages目录中,新建一个sitecustomize.py文件(也可以建在其它地方,然后手工导入,建在这里,每次启动Python的时候设置将自动生效),内容如下:

import sys
sys.setdefaultencoding( 'utf-8' ) #set default encoding to utf-8