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

经过百度发现

Python3字符串默认编码unicode, 所以sys.setdefaultencoding也不存在了。。。。。。

所以删掉就好了。

python3中报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'的更多相关文章

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

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

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

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

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

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

  4. 如果生成allure报告过程中报错AttributeError: module 'allure' has no attribute 'severity_level'

    1.pip uninstall pytest-allure-adaptor 2.pip install allure-pytest 3.搞定 快去吃饭吧

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

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

  6. Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法

    最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...

  7. 使用jieba导入引用方法时,报错AttributeError: module 'jieba' has no attribute 'cut'

    一.问题描述 import jieba导入后,使用jieba.cut()方法时报错AttributeError: module 'jieba' has no attribute 'cut' 二.问题分 ...

  8. [已解决]pycharm报错:AttributeError: module 'pip' has no attribute 'main'

    > 更新pip后,pycharm更新模块报错,经过一番查找,现提供两种解决办法. 报错片段信息如下: AttributeError: module 'pip' has no attribute ...

  9. Centos6.5下安装jumpserver-1.4.1报错AttributeError: module 'gssapi' has no attribute 'GSSException'

    报错: >>> import paramiko Traceback (most recent call last): File "<stdin>", ...

随机推荐

  1. 20170814 新鲜:EChart新增了日历图,要想办法用起来

    比如我可以用下面这个图来展示某个电站的年报,看他之后一年每一天的发电量.  或者是在月报的时候看这个月每天的发电量.这个最妙的时候,他可以通过旁边的图例来筛选,从而产生一个动态的效果.   还有可以在 ...

  2. win7下Google谷歌浏览器上传下载卡死无响应

    问题背景:win7,谷歌浏览器上传选择图片之后,页面卡死无响应. 以前解决过类似问题就是input type="file"的accept属性当为通配符时,会出现这种情况,改为具体的 ...

  3. lsof 查看文件被哪个进程占用

    lsof 是什么意思? 答: list open files 查看某个文件被哪些进程在读写 lsof 文件名 查看某个进程打开了哪些文件lsof –c 进程名lsof –p 进程号 lsof用法小全 ...

  4. Why does Delphi XE7 IDE hangs and fails on out of memory exception?

    引自:   https://stackoverflow.com/questions/27701294/why-does-delphi-xe7-ide-hangs-and-fails-on-out-of ...

  5. 为啥百度、网易、小米都用Python?Python的用途是什么?

      Python是一门脚本语言.由于能将其他各种编程语言写的模块粘接在一起,也被称作胶水语言.强大的包容性.强悍的功能和应用的广泛性使其受到越来越多的关注,想起一句老话:你若盛开.蝴蝶自来. 假设你感 ...

  6. Linux Performance tool

    https://www.tecmint.com/command-line-tools-to-monitor-linux-performance/ https://www.tecmint.com/lin ...

  7. 如何在phpstorm中查看yaf框架源码

    1.到github下载yaf框架的doc 下载链接 https://github.com/elad-yosifon/php-yaf-doc/archive/master.zip 2.解压zip包 3. ...

  8. docker save提示no space left on device错误

    使用df -h看了看,硬盘的确是够用的,于是排除了是硬盘容量的问题. 再细看错误提示: 目录是/var/lib/docker/tmp/docker-export-xxxx/xxxxx,猜测是docke ...

  9. 20款最好的JavaScript开发框架

    JavaScript语言有多种方式,创建交互式网站,Web应用程序.基本的JavaScript框架是预先写好的JavaScript代码集.这些JavaScript框架也被称为JavaScript库,开 ...

  10. Android中的AlarmManager的使用

    AlarmManager是Android中的一种系统级别的提醒服务,它会为我们在特定的时刻广播一个指定的Intent.而使用Intent的时候,我们还需要它执行一个动作,如startActivity, ...