出现情况,输入如下一个函数demo:
run,报错:
SyntaxError: Non-ASCII character 'xe6' in file /Users/XX/PycharmProjects/lesson1Python/pythonTest/ts.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
如何解决?
原因:是因为Python在默认状态下不支持源文件中的编码所致
解决:添加
# coding=utf-8
再次运行,成功
![](https://img2018.cnblogs.com/blog/978914/201903/978914-20190301145745440-1610454840.png)