Python SyntaxError: Non-ASCII character '\xe5'

error:

SyntaxError: Non-ASCII character '\xe5' in file D:\worklife\workshop\myCrawler\src\mainDriver.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

 solve:

python的默认编码文件是用的ASCII码,你将文件存成了UTF-8,解决办法很简单,在文件开头加入
# -*- coding: UTF-8 -*-    或者  #coding=utf-8
posted @ 2014-01-03 10:50  Django's blog  阅读(400)  评论(0编辑  收藏  举报