问题:
在Windows上编写好了py文件,到服务器上去运行时报错
在该段代码:email_txt=hunan+“今日油价:”+hunanoil+“元/升”+“\n”+news 报错
Traceback (most recent call last): File "/another/oil.py", line 152, in <module> UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 0: ordinal not in range(128)
解决:
import sys
defaultencoding = 'utf-8'
if sys.getdefaultencoding() != defaultencoding:
reload(sys