python 解决‘ascii‘ codec can‘t encode characters in position ordinal not in range(128)

2016-10-10 aqi_wolf python

使用java 通过cmd调用python脚本时出现unicodeEncodeError

通过搜索说是读取文件默认是ascii而不是utf8导致的

在代码中加上如下几句即可

import sys

reload(sys)

sys.setdefaultencoding(‘utf8’)

标签: python

发表评论:

Powered by EMLOG Copyright @ 深圳市炽旗科技 版权所有. 闽ICP备14012694号-2