權威來源:http://www.python.org/dev/peps/pep-0263/
Python源文件的頭部聲明(聲明在文件的第一行或第二行)html
# coding=utf-8python
# coding:utf-8express
# -*- coding:utf-8 -*-vim
要符合正則規範"coding[:=]\s*([-\w.]+)" 注意 :或=先後沒有空格學習
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> : More precisely, the first or second line must match the regular expression "coding[:=]\s*([-\w.]+)". The first group of this expression is then interpreted as encoding name. If the encoding is unknown to Python, an error is raised during compilation. There must not be any Python statement on the line that contains the encoding declaration.
PEP 的全名是 Python Enhancement Proposals, "Python 增強建議書" ,它是用來規範與定義 Python 的各種加強與延伸功能的技術規格。this
每個 PEP 都有一個編號並且是惟一的,這個編號一旦給定了就不會再改變,例如,PEP 3000 就是用來定義 Python 3.0 的相關技術規格,而 PEP 333 則是 Python 的 Web 應用程式介面 WSGI (Web Server Gateway Interface 1.0) 的規範.net
關於 PEP 自己的相關規範是定義在 PEP 1,而全部的 PEP 列表則是在這裡code
Read more: http://www.arthurtoday.com/2009/11/python-pep.html#ixzz46oH9oBzVorm
學習:http://blog.csdn.net/orangleliu/article/details/8755461htm