基于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
---------------------
作者:琦彦
来源:CSDN
原文:https://blog.csdn.net/fly910905/article/details/74922378
版权声明:本文为博主原创文章,转载请附上博文链接!

转载于:https://www.cnblogs.com/telwanggs/p/10383182.html

(转)Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding相关推荐

  1. Python3异常-AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘

    Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding' 参考文章: (1)Python3异常-Attr ...

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

    基于python3.6.1版本,在一个.py文件中,加入这3行: import requests, re, sys reload(sys) sys.setdefaultencoding("u ...

  3. python中引入包的时候报错AttributeError: module ‘sys‘ has no attribute ‘setdefaultencoding‘解决方法?

    python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法? 参考文章: (1)pyth ...

  4. AttributeError: module ‘sys‘ has no attribute ‘maxint‘

    AttributeError: module 'sys' has no attribute 'maxint' https://stackoverflow.com/questions/47027354/ ...

  5. python3 opencv AttributeError: module 'cv2' has no attribute '__version__'

    报错:AttributeError: module 'cv2' has no attribute '__version__' AttributeError: module 'cv2' has no a ...

  6. AttributeError: module 'sys' has no attribute 'maxint'

    sys.maxint 改为 sys.maxsize 认识你是我们的缘分,同学,等等,记得关注我. 微信扫一扫 关注该公众号

  7. PyQt5系列(三)Python3.x AttributeError: module 'string' has no attribute 'maketrans'错误解决

    解决: 1./usr/local/lib/python3.6/site-packages/PyQt5/uic/port_v2/ascii_upper.py修改  _ascii_trans_table ...

  8. Python3 AttributeError: module 'cv2' has no attribute 'SIFT'

    参考 https://blog.csdn.net/yuxuan_08/article/details/87966840 在用python3使用sift = cv2.SIFT()进行SIFT时候,可能会 ...

  9. Python3.X识别混合编码,顺便解决“AttributeError: 'module' object has no attribute 'urlopen'”

    原本是想利用chardet模块识别一个混合编码网页的编码类型(以百度为例),然而运行脚本发现python3.X中出现"AttributeError: 'module' object has ...

最新文章

  1. 一步步学会使用ASP.NET 4 WEB应用程序中使用URL Routing(翻译)
  2. 2008年上半年 网络工程师 上下午试卷【附带答案】
  3. C#编程利器系列文章
  4. i++ 和++i的区别
  5. @async 没有异步_spring boot使用@Async异步任务
  6. 很久之前写的【成绩管理系统】的数据库
  7. Hadoop快速入门(一)
  8. 学习笔记9--汽车线控系统技术
  9. 拼多多批发是什么?常见的问题有哪些?
  10. 香港传媒高层访团莅临深之蓝参观访问
  11. 编程之美4.7蚂蚁爬杆扩展问题附猎人抓狐狸(必胜策略)
  12. 群晖docker容器外网访问的问题
  13. 吴恩达深度学习笔记-布置机器学习项目(第4课)
  14. 苹果电脑系统还原出现服务器,苹果电脑恢复出厂设置【解答方法】
  15. 双人成型无法连接远程计算机,《双人成行》无法连接到EA服务器怎么办 无法连接到EA服务器解决办法...
  16. web系统快速开发_开发一个快速销售系统
  17. 为穷苦大众发布的Linux内核新版本
  18. Android手机中的加速度计与陀螺仪
  19. threejs 草场足球运动视角(三)
  20. c++版本opencv(02-第一个OpenCV程序 03.图像加载与保存)

热门文章

  1. gephi生成网络关系图_路网拓扑重建专题 (3) 网络图生成
  2. python 多进程 调用模块内函数_python--多进程的用法详解实例
  3. for循环如果先--_如果再写for循环,我就锤自己!
  4. spark基础之RDD和DataFrame和Dataset比较
  5. (59)简单介绍RAM IP核类型和接口信号?
  6. FPGA RTL级设计原则
  7. 7003.node.js环境搭建及三方软件包
  8. 【其他】编程技巧之常用缩写
  9. 【STM32】【STM32CubeMX】STM32CubeMX的使用之五:定时器时基配置及其中断
  10. (7)哈希表的链地址法实现