AttributeError: module 'sys' has no attribute 'setdefaultencoding'

import sys
reload(sys)
sys.setdefaultencoding("utf-8")

报错:

reload 未声明

然后

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

报错

AttributeError: module 'sys' has no attribute 'setdefaultencoding'

经过百度发现

Python3字符串默认编码unicode, 所以sys.setdefaultencoding也不存在了。。。。。。

所以删掉就好了。

猜你喜欢

转载自www.cnblogs.com/gongzixi/p/8987535.html