SyntaxError:函数返回'£'时文件中的非ASCII字符'\ xa3'说我有一个功能:def NewFunction():
return '£'我想在它前面打一些带有井号的东西,当我尝试运行这个程序时它会输出错误,显示以下错误信息:SyntaxError: Non-ASCII character '\xa3' in file 'blah' but no encoding declared;
see http://www.python.org/peps/pep-0263.html for details谁能告诉我如何在返回功能中加入英镑符号?我基本上是在课堂上使用它,它'__str__'包含在包含英镑符号的部分内。
3 回答

MMMHUHU
TA贡献1834条经验 获得超8个赞
添加以下两行坐在我的.py脚本的顶部为我工作(第一行是必要的):
#!/usr/bin/env python # -*- coding: utf-8 -*-
添加回答
举报
0/150
提交
取消