初学python,做测试例子,出现如上错误,代码如下:
def hello():
hello()
if __name__ == '__main__':test()
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
def hello():
print 'hello~~'
def test():
hello()
如下声明方式均可:
#coding:utf-8
:可以换成=
def hello():
print 'hello~~'
def test():hello()
if __name__ == '__main__':test()
错误信息如下:
File "D:\python\pythons\src\test.py", line 20SyntaxError: 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
def hello():
print 'hello~~'
def test():
hello()
if __name__ == '__main__':test()
红色部分为编码声明!如下声明方式均可:
#coding:utf-8
:可以换成=