美文网首页
Python3异常-AttributeError: module

Python3异常-AttributeError: module

作者: 乱世佳人_c160 | 来源:发表于2018-07-08 20:39 被阅读0次

  基于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

转自:https://blog.csdn.net/fly910905/article/details/74922378

相关文章

网友评论

      本文标题:Python3异常-AttributeError: module

      本文链接:https://www.haomeiwen.com/subject/vrfauftx.html