码迷,mamicode.com
首页 > 编程语言 > 详细

python reload(sys)找不到,name 'reload' is not defined和Python3异常-AttributeError: module 'sys' has no att

时间:2019-01-27 19:01:21      阅读:416      评论:0      收藏:0      [点我收藏+]

标签:存在   blog   default   出现   csdn   unicode   版本   sdn   .net   

基于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
版权声明:本文为博主原创文章,转载请附上博文链接!

python reload(sys)找不到,name 'reload' is not defined和Python3异常-AttributeError: module 'sys' has no att

标签:存在   blog   default   出现   csdn   unicode   版本   sdn   .net   

原文地址:https://www.cnblogs.com/telwanggs/p/10326804.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!