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. SeaweedFS的配置使用

    SeaweedFS是一个简单并且高度可扩展的分布式文件系统,可以存储数十亿的文件并且快速获得文件,特别适合于有效处理小文件,这里我们简称为weed,weed的主节点不管理文件元数据而是仅管理文件卷,这 ...

  2. java 线程间的通信 (wait / notify / notifyAll)

    package waitnotifytest; import java.util.Collections; import java.util.List; import com.google.commo ...

  3. MATLAB 统计元素出现的次数

    可以使用 hist 函数: A = [1 2 8 8 1 8 2 1 8 2 1]; count = hist(A,unique(A)) count的结果与unique(A)对应.

  4. What is a Back Order

    What is a Back Order A back order is a customer order that has not been fulfilled. A back order gene ...

  5. CentOS 7.4上网速度慢,修改DNS!

    修改下DNS,vi /etc/resolv.conf 原来配置: nameserver 223.5.5.5 修改为: nameserver 114.114.114.114 

  6. 简单理解PHP-FPM

    php-fpm只是一个php-fastcgi的管理器,为php提供管理服务 1.为什么会出现php-fpm    fpm的出现全部因为php-fastcgi出现,为了很好的管理php-fastcgi而 ...

  7. Deep Reinforcement Learning

    Reinforcement-Learning-Introduction-Adaptive-Computation http://incompleteideas.net/book/bookdraft20 ...

  8. 【将门创投】AI 往期技术分享

    计算机视觉 1. 嘉宾:商汤科技CEO 徐立 文章回顾:计算机视觉的完整链条,从成像到早期视觉再到识别理解 2. 嘉宾:格灵深瞳CTO 赵勇 文章回顾:计算机视觉在安防.交通.机器人.无人车等领域的应 ...

  9. VirtualBox通过Host-Only网络连接方式实现宿主机与虚拟机通信

    适用情况 (1)没有联网, 不插网线 (2)宿主机直接连接宽带(无路由器) 情景: 宿主机 Windows 7 虚拟机 Windows XP 虚拟机安装了SQLServer2005,宿主机想连接使用虚 ...

  10. java改单个插入为批量插入

    单条insert into table value() 13W数据需要执行7小时 变成inert into table value(),(),(),(),() inert into table val ...