Python中出现Non-UTF-8 code错误的解决方法
错误信息:
Non-UTF-8 code starting with ‘\xc4’ in file main.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
解决方案:
在代码头部添加一句注释:
# coding=utf-8
或者加入:
import sys reload(sys) sys.setdefaultencoding('utf-8')
尝试之后仍然报错,将文件另存为utf8格式,搞定