AttributeError: module 'sys' has no attribute 'setdefaultencoding
时间: 2023-09-03 07:09:12 浏览: 198
这个报错是因为在Python 3中,sys库已经没有setdefaultencoding()函数了。这个函数在Python 2中用于设置默认编码,但在Python 3中已经不再需要,因为Python 3默认使用的就是utf-8编码。所以,你可以直接删除import sys import importlib importlib.reload(sys) sys.setdefaultencoding("utf-8")这段代码即可。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [【python报错】AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding](https://blog.csdn.net/SLXii/article/details/130765423)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文