UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)
py文件直接在cmd窗口用python命令执行时正常;代码逐句在ipython中也正常;但是,
在wingIDE中运行报错“UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-3: ordinal not in range(128)”
解决方案是在python的Lib文件夹下新建一个sitecustomize.py,内容为:
1 # coding=utf-8 2 import sys 3 4 reload(sys) 5 sys.setdefaultencoding('utf-8')