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

时间:2016-07-10 21:22:52   收藏:0   阅读:2225
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‘)

 技术分享

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!