推荐使用
#!/usr/bin/python # -*- coding: utf-8 -*-
引用 http://legacy.python.org/dev/peps/pep-0263/
Defining the Encoding
Python will default to ASCII as standard encoding if no other encoding hints are given. 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> :
转载于:https://blog.51cto.com/huangchao/1665606