Go
#-*-Coding:utf-8-*-The main role is to specify the file encoding for Utf-8, because the general default is the ASCII code, if you want to write Chinese in the file, the runtime will appear garbled, plus this sentence will be converted to utf-8 the file code will not appear garbled.
Declarative syntax reference for Python pep http://www.python.org/dev/peps/pep-0263/
The main contents are as follows:
1. The code note must be placed on the first or second line
2. The optional format is
# coding=<encoding Name>
#-*-Coding: <encoding name>-*-
# Vim:set fileencoding=<encoding name>:
3. The standard gives a valid string as long as it satisfies the following regular expression:
\%^.*\n.? \?#.*coding[:=]\s*[0-9a-za-z-_.] \+.*$
The meaning of this is that # must be included, and the # number cannot be preceded by other characters such as character wrapping, and the string must contain coding followed by: or = Next is the encoded name.
But why is this usually the way it is?
#-*-Coding: <encoding name>-*-
The answer is mentioned in PEP-0263, that is, Emacs and other editors use this way to encode the declaration. This writing can support a variety of editors, good portability.
Reference Documentation:
http://www.python.org/dev/peps/pep-0263/
http://blog.csdn.net/arbel/article/details/7957782
Code comment for Python #-*-Coding:utf-8-*-