SyntaxError: Non-ASCII character '\xe6' in file people.py on line 34, but no encoding declared;
文中提到:
To define a source code encoding, a magic comment must be placed into the source files either as first or second line in the file, such as:
# coding=<encoding name>
or (using formats recognized by popular editors)
#!/usr/bin/python # -*- coding: <encoding name> -*-
or
#!/usr/bin/python # vim: set fileencoding=<encoding name> :
Example:
|
Result:
Python是個酷玩意
錯誤訊息中的連結到這篇文章:
PEP 0263 — Defining Python Source Code Encodings