#的英文: Pound character or Octothorpe
Python single-line comments with #, multiline comments with "" ", see the following code:
1 #!/usr/bin/python2 #Coding:utf-83 4 5 #Encoding Method6 7 #Print a line *8 9 Print "********************" #I'm a note too .Ten One """ A I'm a multi-line comment - """ - the Print "Did you not see me as a description of the multiline comment"
Results:
Under special instructions:
Why #coding:utf-8 can play a role?
We refer to the official Python documentation to find that this is a well-defined, total of three ways, the third way to use the regular expression, interested can be studied. Website: https://www.python.org/dev/peps/pep-0263/
The purpose of this pep is to describe how the encoding syntax is declared in a Python source file. The Python interpreter then uses the encoded information when interpreting the file. The most notable is the interpretation of Unicode in the source file, making it possible to use such as FUT-8 encoding in a Unicode-aware editor
1Python would default to ASCII as standard encodingifNo other encoding hints is given.2 3To define a source code encoding, a magic comment must is placed into the source files either as firstorSecond lineinchthe file, such as:4 5 #coding=<encoding name>6 or(using formats recognized by popular editors):7 8 #!/usr/bin/python9 #-*-Coding: <encoding name>-*-Ten or: One A #!/usr/bin/python - #vim:set fileencoding=<encoding name>: -More precisely, the firstorsecond line must match the following regular expression: the -^[\t\v]*#. *?coding[:=][\t]* ([-_.a-za-z0-9]+) -The first group of this expression isThen interpreted as encoding name. If the encoding isUnknown to Python, an error isRaised during compilation. There must notBe any Python statement on the line that contains the encoding declaration. If the first line matches the second line isignored. - +To aid with platforms such as Windows, which add Unicode BOM marks to the beginning of Unicode files, the UTF-8 signature \XEF\XBB\XBF'll be interpreted as'Utf-8'Encoding as well (evenifNo magic encoding Comment isgiven). - +If a source file uses both the UTF-8 BOM mark Signature andA magic encoding comment, the only allowed encoding forThe comment is 'Utf-8'. Any other encoding would cause an error.
python--notes