pyhon SyntaxError: Non-ASCII character '\xe8' in file xxx on line xx, but no encoding

import math

if __name__ == '__main__':
    name1 = raw_input("请输入您的编号:")
    print name1

完整的错误信息如下:

  File "D:\python\pythons\src\test.py", line 20
SyntaxError: Non-ASCII character '\xe8' in file D:\python\pythons\src\test.py on line 20, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

缺少编码类型声明:no encoding declared

修改如下:

#encoding:utf-8
import math

if __name__ == '__main__':
name1 = raw_input("请输入您的编号:")
print name1

 

posted on 2018-07-27 10:17  乐学习  阅读(636)  评论(0编辑  收藏  举报

导航