Python问题分析:AttributeError: module 'sys' has no attribute 'setdefaultencoding'
2017-12-13 17:57
2281 查看
问题描述
AttributeError: module 'sys' has no attribute 'setdefaultencoding'
样例代码
import sys sys.setdefaultencoding('utf-8')
问题分析
目前的Python版本是3.6.1,其默认的编码格式是utf-8。》import sys
》sys.getdefaultencoding()
‘utf-8’
所以在新版本的python中,已经不支持setdefaultencoding函数了。
解决方法
直接移除掉即可。补充说明
import sysreload(sys)
reload函数在此Python版本下也不再支持了,直接移除掉即可。
相关文章推荐
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- python错误:AttributeError: 'module' object has no attribute 'setdefaultencoding'问题的解决方法
- Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding'
- python AttributeError: 'module' object has no attribute 'setdefaultencoding'
- AttributeError: module 'sys' has no attribute 'setdefaultencoding'
- Tensorflow protobuf版本报错问题解决(AttributeError: 'module' object has no attribute 'Default')
- Python3下AttributeError: 'dict' object has no attribute 'iteritems'的问题分析
- 'module' object has no attribute 'setdefaultencoding'_阿King's blog_百度空间
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- 学习Python csv模块遇到AttributeError: module 'csv' has no attribute 'writer'和写入后出现空格问题
- Python3下AttributeError: 'dict' object has no attribute 'iteritems'的问题分析
- python运行不了 AttributeError: module object has no attribute getdefaultlocale
- 解决python中问题AttributeError: 'collections.defaultdict' object has no attribute 'iteritems'
- python3.6脚本import json模块后,报错:AttributeError: module 'json' has no attribute 'dumps'
- 'module' object has no attribute 'MLPRegressor'问题解决(Python2.7)
- AttributeError 'module' object has no attribute 'handlers'--Python子模块导入问题
- web.py 直接使用示例代码,web.application报错, 'module' object has no attribute 'application',问题原因分析
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
- python3 报错: AttributeError: 'module' object has no attribute 'urlopen'