Notes
The comment is the explanation and description of the code. The purpose is to make it easy for others to understand. In order to let others know what this code is for at a glance. The correct program notes generally include preface notes and functional notes. The main content of the preamble comment includes the interface of the module, the description of the data and the function of the module. The main content of the functional comment of the module includes the function of the block, the function of the sentence and the state of the data.
Classification of annotations
1. Single line comment
Start with #, and everything on the right side of # is used as an explanation, not the actual program to be executed, and serves as an auxiliary explanation
I am a comment, you can write a functional description here
print("My above line is a comment to me")
2. Multi-line comments
Multi-line comments can be three pairs of double quotation marks or three pairs of single quotation marks. Yes, you have heard it right. There are three pairs. None of them can be less. Also, single quotation marks and double quotation marks can be used, but don’t be foolish. A double quotation mark, three single quotation marks on one side, single quotation marks are single quotation marks, and double quotation marks are double quotation marks.
"""
I am multi-line comment 1
I am multi-line comment 2
I am multi-line comment 3"""
print("My above is a multi-line comment")
Content supplement:
We can output the comment of the function in the following example:
def a():'''This is the docstring'''
pass
print(a.__doc__)
This is the end of this article on how to annotate python code. For more information about how to annotate python, please search ZaLou.Cn
Recommended Posts