当前位置: 代码迷 >> Ruby/Rails >> python实践出错:SyntaxError: Non-ASCII character
  详细解决方案

python实践出错:SyntaxError: Non-ASCII character

热度:1004   发布时间:2016-04-29 02:07:21.0
python实践报错:SyntaxError: Non-ASCII character

报错: File "C:\001myWorkspace\001myWork\workspace2\MyFirstPython\src\demo4\demo4-2.py", line 21
SyntaxError: Non-ASCII character '\xe5' in file C:\001myWorkspace\001myWork\workspace2\MyFirstPython\src\demo4\demo4-2.py on line 21, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
如图:

image

分析:SyntaxError: Non-ASCII character 可看出是用于编码格式出问题了

解决方案:

1、在文件第一行添加: # encoding:utf-8

image

  相关解决方案