(转)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& ...
随机推荐
- 深入出不来nodejs源码-V8引擎初探
原本打算是把node源码看得差不多了再去深入V8的,但是这两者基本上没办法分开讲. 与express是基于node的封装不同,node是基于V8的一个应用,源码内容已经渗透到V8层面,因此这章简述一下 ...
- winform窗体 小程序【移动窗体和阴影】
窗体无边框设置后无法移动,引用API 使其获得功能 移动 //窗体移动API [DllImport("user32.dll")] public static extern bool ...
- [javaEE] Servlet的调用过程和生命周期
在http协议的请求头中获取到要访问的资源,查找web.xml文件找到对应的servelet Sevlet的生命周期 Servlet在第一次被访问的时候,服务器创建出Servlet对象,创建出对象以后 ...
- Vue:模板&渲染函数学习
模板&渲染函数区别: 1.代码量:模板代码重复逐行拼写,渲染函数可以迭代拼接方式实现重复代码. 2.函数式组件中应用:基于模板的函数式组件需要手动添加特性和事件,给予渲染函数的函数是组件使用c ...
- EF框架的code first
需要添加EntityFramework的引用,在NuGet(在工具--库程序包管理--程序包管理控制台) 控制台输入Install-Package EntityFramework,目前版本是6.1.3 ...
- Velocity快速入门
Velocity 介绍 Velocity是一个基于java的模板引擎.它允许任何人使用简单但功能强大的模板语言引用Java代码中定义的对象. 当Velocity用于web开发时,web设计人员可以与J ...
- HDU2389(KB10-F 二分图最大匹配Hopcroft_Karp)
Rain on your Parade Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 655350/165535 K (Java/Ot ...
- CSS计数器(序列数字字符自动递增)详解———张鑫旭
by zhangxinxu from http://www.zhangxinxu.com本文地址:http://www.zhangxinxu.com/wordpress/?p=4303 一.挖坟不可耻 ...
- 关于JavaScript原型对象那些事儿
①为什么要使用原型:为了实现继承. ②利用constructor属性可以让实例化对象轻松访问原型,实现实例化对象对原型对象的修改,但是原型对象是全局对象,一般不能随意修改原型对象的成员.该属性多用于调 ...
- instanceof与constructor的区别
名词介绍 instanceof 的作用是判断实例对象是否为构造函数的实例,实际上判断的是实例对象的__proto__属性与构造函数的prototype属性是否指向同一引用: constructor 的 ...