Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding'


基于python3.6.1版本,在一个.py文件中,加入这3行:

import requests, re, sys
reload(sys)
sys.setdefaultencoding("utf-8")

出现这样的错误:

sys.setdefaultencoding("utf-8")
AttributeError: module 'sys' has no attribute 'setdefaultencoding' 

原因分析:

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

解决:

去掉,sys.setdefaultencoding


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM