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
...