Python 3中使用中文字符報錯

Python 3中使用中文字符報錯

[Running] python -u "d:\CreatingSpace\VSCode\Python36\catelog\cat.py"
  File "d:\CreatingSpace\VSCode\Python36\catelog\cat.py", line 17
SyntaxError: Non-ASCII character '\xe5' in file d:\CreatingSpace\VSCode\Python36\catelog\cat.py on line 17, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

SyntaxError: Non-ASCII character '\xe5' in file

解決方法
未添加文件編碼,在文件首行添加編碼信息即可。

# coding=<encoding name>
import sys,os
...
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章