(转)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
---------------------
作者:琦彦
来源:CSDN
原文:https://blog.csdn.net/fly910905/article/details/74922378
版权声明:本文为博主原创文章,转载请附上博文链接!
(转)Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding的更多相关文章
- Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding'
基于python3.6.1版本,在一个.py文件中,加入这3行: import requests, re, sys reload(sys) sys.setdefaultencoding("u ...
- python reload(sys)找不到,name 'reload' is not defined和Python3异常-AttributeError: module 'sys' has no att
基于python3.6.1版本,在一个.py文件中,加入这3行:import requests, re, sysreload(sys)sys.setdefaultencoding("utf- ...
- python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?
python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...
- python3中报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'
reload(sys) sys.setdefaultencoding("utf-8") f = open('.\\24.novel.txt','rb') str = f.read( ...
- Python AttributeError: module 'sys' has no attribute 'setdefaultencoding'
Python 3 与 Python 2 有很大的区别,其中Python 3 系统默认使用的就是utf-8编码. 所以,对于使用的是Python 3 的情况,就不需要sys.setdefaultenco ...
- AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'
/*************************************************************************** * AttributeError: 'modu ...
- AttributeError: module 'enum' has no attribute 'IntFlag'
Mac PyCharm新建以Python3.6.1为解释器的Django项目的时候出现以下错误提示: AttributeError: module 'enum' has no attribute 'I ...
- Python 3.6安装yaml时报"AttributeError: module 'pip' has no attribute 'main'"和“Non-zero exit code”错误
1.Python 3.6安装yaml时一开始报AttributeError: module 'pip' has no attribute错误,根据网上提供的解决方法修改Pycharm安装目录D:\Pr ...
- AttributeError: 'module' object has no attribute 'main'
本机环境:ubuntu16.04, ros-kinetic $ roscore 报错 Traceback (most recent call last): File , in <module& ...
随机推荐
- [转]Magento2开发教程 - 如何向数据库添加新表
本文转自:https://www.cnblogs.com/xz-src/p/6920365.html Magento 2具有特殊的机制,允许你创建数据库表,修改现有的,甚至添加一些数据到他们(如安装数 ...
- python与中文的那点事
目录 python与中文的那点事 1. utf-8/gbk/unicode/ASCII 2.各种编码之间的转换 3. 统计字符串中数字,字母,汉字的个数 python与中文的那点事 在学习python ...
- HDU2643(SummerTrainingDay05-P 第二类斯特林数)
Rank Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submis ...
- POJ1284(SummerTrainingDay04-K 原根)
Primitive Roots Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4505 Accepted: 2652 D ...
- 'QuerySet' object has no attribute '_meta'
'QuerySet' object has no attribute '_meta' 对象列表没有'_meta'属性 单独的对象才有, 忘记加first了 edit_obj = models.Role ...
- 初学HTML-3
标题标签:<h#>...</h#>,从h1到h6,字号由大变小. 段落标签:<p>...</p>,在浏览器中独占一行. 空格:" " ...
- cf711D. Directed Roads(环)
题意 题目链接 \(n\)个点\(n\)条边的图,有多少种方法给边定向后没有环 Sol 一开始傻了,以为只有一个环...实际上N个点N条边还可能是基环树森林.. 做法挺显然的:找出所有的环,设第\(i ...
- js-ES6学习笔记-let命令
1.let命令 ES6新增了let命令,用来声明变量.它的用法类似于var,但是所声明的变量,只在let命令所在的代码块内有效. for循环的计数器,就很合适使用let命令. 下面的代码如果使用var ...
- @NotNull、@NotEmpty、@NotBlank的区别
Spring中@NotNull.@NotEmpty.@NotBlank的区别@NotNull:用于基本数据类型@NotEmpty:用于集合类@NotBlank:用于String上面
- html5的web存储与cookie的区别
以下从3个方面进行比较: 1,容量:cookie只有4KB,localStorage和sessionStorage最大容量5M 2,是否会携带到ajax中:cookie由每个对服务器的请求来传递,会影 ...