SyntaxError: Non-ASCII character 'æ' in file csdn.py on line 7, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

错误信息:

1
2
SyntaxError: Non-ASCII character 'æ' in file csdn.py on line 7, but no
encoding declared; see http://python.org/dev/peps/pep-0263/ for details

错误原因:
原因是因为Python在默认状态下不支持源代码中的编码所致。

解决方案:
在Python文件开头加上# -*- coding: utf-8 -*即可解决该问题

文章目录