python中引入包的时候报错:
import unittest
import smtplib
import time
import os
import sys
imp.reload(sys)
sys.setdefaultencoding('utf-8')

AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法:

1.python2中解决方法:
reload(sys)
sys.setdefaultencoding('utf-8')

2.python3中解决方法:
imp.reload(sys)
sys.setdefaultencoding('utf-8')

python中引入包的时候报错AttributeError: module 'sys' has no attribute 'setdefaultencoding'解决方法?的更多相关文章

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

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

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

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

  3. 【pycharm】pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法

    pycharm上安装tensorflow,报错:AttributeError: module 'pip' has no attribute 'main' 解决方法 解决方法: 在pycharm的安装目 ...

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

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

  5. python文件名不要跟模块名相同,报错AttributeError: 'module' object has no attribute 'Differ'

    python中的文件都会生成pyc文件,包括模块也是这样,所以调用模块的时候,实际上会调用模块.pyc文件:在这个前提下,如果将文件名命名成跟模块名一样,在同一目录下就会生成一个跟模块名一样的pyc文 ...

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

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

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

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

  8. unittest模块在linux报错: AttributeError: module 'unittest' has no attribute 'TestRunner'

    一开始在windows下运行没有问题,但是在linux下运行却报如下错误: ​ AttributeError: module 'unittest' has no attribute 'TestRunn ...

  9. 运行pytest,报错"AttributeError: 'module' object has no attribute 'xxx'"

    最近学习pytest被此问题困扰,敲脑壳,实在是不该.百度解决方法一大堆,我的问题怎么也解决不了,来看一下,我是怎么解决的,各位大佬勿喷,只是自己做笔记用,谢谢. 报错信息如下: 网上解决方法是这样的 ...

随机推荐

  1. 省市区三级联动 pickerView

    效果图 概述 关于 省市区 三级联动的 pickerView,我想大多数的 iOS 开发者应该都遇到过这样的需求.在遇到这样的需求的时候,大多数人都会觉的这个很复杂,一时无从下手.其实真的没那么复杂. ...

  2. JavaWeb结合七牛云存储搭建个人相册服务

    JavaWeb结合七牛云存储搭建个人相册服务 一.引言1. 课程概述 相信很多人都知道网站一般会有很多图片,对于小型网站来说,图片放在网站服务器上不算什么,但当图片数量很大时,会造成服务器很臃肿,相应 ...

  3. 使用putty与SSHSecureShellClient登录远程服务器完成与本地Git项目的同步

    使用软件远程登录管理服务器 今天给大家介绍两款远程登录管理服务器的软件(Putty和SSHSecureShellClient),这两款也是我在工作中经常的软件. 使用 PuTTY 远程登录管理服务器 ...

  4. Perl 脚本报Can't locate Mail/Sender.pm 解决办法

        在新的Linux Server(Red Hat Enterprise Linux Server release 5.7 (Tikanga))上配置磁盘空间告警的perl脚本后,测试时报如下错误 ...

  5. jstorm集群部署

    jstorm集群部署下载 Install JStorm Take jstorm-0.9.6.zip as an example unzip jstorm-0.9.6.1.zip vi ~/.bashr ...

  6. 【转】js 关键字 in 的使用方法

    js 关键字 in 的使用方法  原文地址:http://sunct.iteye.com/blog/1709017   1.For...In 声明用于对数组或者对象的属性进行循环/迭代操作. 对于数组 ...

  7. Linux 命令学习

    当前登陆目录:

  8. Linux--shell脚本之正则表达式

    一.正则表达式的概念及特点: 正则表达式是对字符串操作的一种逻辑公式,就是用事先定义好的一些特定字符.及这些特定字符的组合,组成一个“规则字符串”,这个“规则字符串”用来表达对字符串的一种过滤逻辑.规 ...

  9. 洛谷P1605 迷宫——S.B.S.

    题目背景 迷宫 [问题描述] 给定一个N*M方格的迷宫,迷宫里有T处障碍,障碍处不可通过.给定起点坐标和 终点坐标,问: 每个方格最多经过1次,有多少种从起点坐标到终点坐标的方案.在迷宫 中移动有上下 ...

  10. LCA 倍增||树链剖分

    方法1:倍增 1498ms #include <iostream> #include <cstdio> #include <algorithm> #include ...