An alternative method for implementing multi-line annotation in Python, and multiple-line annotation in python
Python program comments are very difficult. For those who are used to using/**/multi-line comments, it is very painful to use the # sign to annotate a single line in Python.
Copy codeThe Code is as follows:
# Here is a single line comment
# A = 50
# B = 10
# C = 10
In fact, we can implement multi-line comments through the format defined by multi-line text:
Copy codeThe Code is as follows:
"""
# Multiline comments
A = 50
B = 10
C = 10
"""
This method is not bad. It is no different from/**/multi-line comments, which is useful when debugging code. You can directly use multi-line text definition symbols to comment out some code. Maybe the multi-line text definition function of Python can also be used as annotation, but the Manual does not explicitly write it for multi-line annotation.
Python multi-line comment
This is the annotation method. You can take a look at it. It is estimated that it is the single quotation marks in you, and the double quotation marks do not match.
How to add a comment for python?
# Single line comment
'''
Multi-line comment
Multi-line comment
Multi-line comment
'''
Annotations cannot be displayed during running.
During running, only print is allowed