解决eclipse编辑python程序的SyntaxError: Non-ASCII character错误

时间:2014-05-01 22:00:23   收藏:0   阅读:440

  错误信息如下:

File "E:\work\pydev\pythodemo\src\code\string.py", line 1

SyntaxError: Non-ASCII character ‘\xe5‘ in file E:\work\pydev\pythodemo\src\code\string.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details


错误图如下:

mamicode.com,码迷


源代码:

dic = {"name":"张三","age":30,"gender":"男"}
print dic

原因:由程序中出现中文导致的


解决方法:

源码文件第一行加上:

#  -*- coding: utf-8 -*-


解决eclipse编辑python程序的SyntaxError: Non-ASCII character错误,码迷,mamicode.com

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