错误信息如下:
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 -*-