Python single-line comments, annotations use the whole

There are many comments in Python, there are single-line comments, multiline comments, batch comment, the comment is also commonly used in Chinese.

Notes python also has its own norms, in the article will be introduced to.

Notes Notes can play a role, when teamwork, personal code that will be written often people call, in order to make it easier for others to understand thoroughfare of code, the comment is very effective.

A, python single line comment (#)

Pound sign (#) is often used as a single line comment symbol, when used in code #, no data will be ignored to its right, as a comment.

>>> # Print ( "the Hello Python") 
>>> Print ( " has been annotated, can not output! " ) 
Has been annotated, can not output!

 # Number to the right of the content at the time of execution will not be output.

Second, the volume, multi-line comments symbols
in python a lot of time there will be annotated with the line, in which case you need a break bulk multi-line comments.

Multi-line comment with triple quotes '' '' '' or a pair of three single quotes included, for example:

'' ' 
Print ( "la la la") 
Print ( "la la la") 
Print ( "la la la") 
Print ( "la la la") 
Print ( " la la la la la la ") 
'' '

Third, involving Chinese

When writing code in python, there will not avoid or use Chinese, this time you need to add Chinese annotation in the beginning of the file.

If you do not declare the beginning of what is stored encoded format, then it will use the default file save ASKII code, then if you have Chinese code will be wrong, even if your Chinese is included in the notes inside.

So add Chinese annotation is very important.

# coding = utf-8
, or:
# = GBK Coding

 

Guess you like

Origin www.cnblogs.com/jiameng991010/p/11225223.html