源自:2-4 Python实例属性的初始化
File "index.py", line 9 SyntaxError: Non-ASCII character '\xe5' in file index.py on line 9, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
错误点dog = Animal('小花',19), python2中如果源代码文件包含非ASCII字符,您需要在文件的顶部声明文件的编码,否则解释器无法正确解析这些字符。# -*- coding: utf-8 -*-
提问者:慕先生8335127
2024-03-07 12:31
个回答
-
代码第一行指定:
# -*- coding: utf-8 -*-