python 运行时报错误SyntaxError: Non-ASCII character '\xe5' in file 1.py on line 2

File "1.py", line 2
SyntaxError: Non-ASCII character '\xe5' in file 1.py on line 2, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

 

 

原因是:Python默认是以ASCII作为编码方式的,需要在文件开头设置一下编码

# -*- coding: UTF-8 -*-     
或者 
#coding=utf-8

 

posted @ 2015-07-13 15:57  KoMiles  阅读(7926)  评论(0编辑  收藏  举报