Home > Article > Backend Development > What is the comment method in python? Introduction to python annotation method
This article brings you what is the annotation method of Python? The introduction of python annotation method has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
Each computer language has its own comment method. We know that the function of comments is to explain what these codes are, so that they can be understood at a glance and facilitate future inspection and modification.
The commented part has no effect during the running of the program and will not be displayed.
Let’s take a look at the comment method:
1. Single-line comment We can use the # sign to comment
eg: nav = 1 #This is to declare a variable nav
print(nav) #Print the result of nav here
#print(nav) This can also make the line of code have no effect
2. Multi-line comments We can Use pairs of ''' code''' to comment out three lines with three pairs of single quotes, or three pairs of double quotes to comment out three lines. Of course, you can also comment out more.
eg:
nav = 1 nav2 = 2 nav3 = nav + nav2 print(nav3)
This is the original code, then I need to comment out three of the lines with single quotes, we can do this, as follows:
'''nav = 1 nav2 = 2 nav3 = nav + nav2''' 这样以上三行就注释掉了。 print(nav3)
Double quote comments The method is the same as the single quote comment method, so we can use these methods to comment.
The above is the detailed content of What is the comment method in python? Introduction to python annotation method. For more information, please follow other related articles on the PHP Chinese website!