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

Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding'的更多相关文章

  1. (转)Python3异常-AttributeError: module 'sys' has no attribute 'setdefaultencoding

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

  2. 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- ...

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

    python中引入包的时候报错:import unittestimport smtplibimport timeimport osimport sysimp.reload(sys)sys.setdef ...

  4. python3中报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'

    reload(sys) sys.setdefaultencoding("utf-8") f = open('.\\24.novel.txt','rb') str = f.read( ...

  5. Python AttributeError: module 'sys' has no attribute 'setdefaultencoding'

    Python 3 与 Python 2 有很大的区别,其中Python 3 系统默认使用的就是utf-8编码. 所以,对于使用的是Python 3 的情况,就不需要sys.setdefaultenco ...

  6. AttributeError: 'module' object has no attribute 'TornadoAsyncNotifier'

    /*************************************************************************** * AttributeError: 'modu ...

  7. AttributeError: module 'enum' has no attribute 'IntFlag'

    Mac PyCharm新建以Python3.6.1为解释器的Django项目的时候出现以下错误提示: AttributeError: module 'enum' has no attribute 'I ...

  8. 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 ...

  9. AttributeError: 'module' object has no attribute 'main'

    本机环境:ubuntu16.04,  ros-kinetic $ roscore 报错 Traceback (most recent call last): File , in <module& ...

随机推荐

  1. Outlook 2016 自动发送/接收无法正常工作

    如果您的自动/发送接收由于某种原因停止工作,可能会非常令人沮丧,因为您必须记住手动执行发送/接收(F9).如果您遇到Outlook无法自动发送或接收电子邮件的问题,可以尝试以下几项操作. #1 发送/ ...

  2. OpenGL小试牛刀第一季

    效果截图:代码展示:using System;using System.Collections.Generic;using System.ComponentModel;using System.Dat ...

  3. Context 使用不当造成内存泄露

    问题: Activity中的context被传递给了一个生命周期长过activity的对象(通常为静态单实例变量),导致activity不能正常被销毁. 示例:Activity 调用 ChatMgr ...

  4. jQuery如何获取选中单选按钮radio的值

    使用jquery获取radio的值,最重要的是掌握jquery选择器的使用,在一个表单中我们通常是要获取被选中的那个radio项的值,所以要加checked来筛选,比如有以下的一些radio项: 1. ...

  5. TFS2018 找不到JRE 错误

    配置TFS 2018 server configurion 报错 : Search requires Oracle Server JRE 7 Update 55 or higher or JRE 8 ...

  6. python 与 json

    +-------------------+---------------+    | Python            | JSON          |    +================= ...

  7. Word2vec资料

    Word2vec 很好的资料 Word2Vec-知其然知其所以然   https://www.zybuluo.com/Dounm/note/591752 Word2Vec数学原理讲解 http://w ...

  8. javaweb基础(13)_session防止表单重复提交

    在平时开发中,如果网速比较慢的情况下,用户提交表单后,发现服务器半天都没有响应,那么用户可能会以为是自己没有提交表单,就会再点击提交按钮重复提交表单,我们在开发中必须防止表单重复提交. 一.表单重复提 ...

  9. xmpp 协议详解

    XMPP(可扩展消息处理现场协议)是基于可扩展标记语言(XML)的协议,它用于即时消息(IM)以及在线现场探测.它在促进服务器之间的准即时操作.这个协议可能最终允许因特网用户向因特网上的其他任何人发送 ...

  10. 关于在vue 中使用百度ueEditor

    1. 安装  npm i vue-ueditor --save-dev 2.从nodemodels  取出ueditor1_4_3_3 这整个目录,放入vue 的 static 目录 3.配置 ued ...