Think before you speak, read before you think.

python非英文国家编码问题

python运行错误

File "ex3.py", line 1
SyntaxError: Non-ASCII character '\xe5' in file ex3.py on line 1, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

我只是在注释里加了中文,同样错误,现在在python脚本的头部加入

# -- coding: utf-8 --

这样就使用了utf-8编码,就不会出错了。

 


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *