当前位置: 代码迷 >> Ruby/Rails >> 解决eclipse编辑python程序的SyntaxError: Non-ASCII character异常
  详细解决方案

解决eclipse编辑python程序的SyntaxError: Non-ASCII character异常

热度:632   发布时间:2016-04-29 02:25:59.0
解决eclipse编辑python程序的SyntaxError: Non-ASCII character错误

  错误信息如下:

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


错误图如下:



源代码:

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

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


解决方法:

源码文件第一行加上:

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


  相关解决方案