SyntaxError: Non-ASCII character '\xe5' in file 的解决办法

当你使用使用python3写好的python程序使用python2运行时,或者在运行你的python程序时,出现了一下错误:

SyntaxError: Non-ASCII character ‘\xe5’ in file figure4_5.py on line 22, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

这是因为程序编码有问题,只需要在你程序开始的地方加入(程序最最顶端)以下代码即可:

#!usr/bin/python
# -*- coding: utf-8 -*-

猜你喜欢

转载自blog.csdn.net/weixin_40612082/article/details/80543460