Objective
Annotations can play a role in a note, when the team work, the individual code is often called by many people, in order to make it easier for others to understand the thoroughfare of the Code, the use of annotations is very effective.
Python annotation Character
One, Python single-line annotation symbol (#)
The pound sign (#) is often used as a single-line annotation symbol, and any data on the right side of it is ignored as a comment when using # in code.
#号右边的内容在执行的时候是不会被输出的.
Second, batch, multiline annotation symbol
There are also many lines of annotations in Python, in which case a lot of multiline annotation characters are required. Multiline annotations are contained in triple quotes ' ', such as:
Some people may say that this is not confused with a multi-line string, but many of the programmers I see are doing the same, and it's good to be careful when using them.
Three, Python Chinese annotation method
When you write code in Python, you don't have to be able to see or use Chinese, you need to add a Chinese comment at the beginning of the file. If the beginning does not declare what the format of the saved encoding is, then it defaults to saving the file with the Askii code, so if you have Chinese in your code, it will go wrong, even if your Chinese is included in the annotation. So it's important to add a Chinese annotation.
#coding =utf-8
or:
#coding =GBK
Hint: Both of the above can represent the Chinese annotation, I have seen more people use urf-8 this kind of more.
Summarize
A good programmer, it is necessary to annotate code. But make sure that annotations are important things, like a glimpse of what you're doing, and that useless code doesn't need to be commented on. The above is the entire content of this article, I hope the content of this article for everyone's study or work can bring certain help.