This article mainly introduces an alternative method for implementing multi-line annotation in Python. This article uses the Python multi-line text function to implement multi-line annotation in Python, if you need a friend, you can refer to the comments of the Python program and feel like a group. For those who are used to using/**/multi-line comments, in Python, it is very painful to use # to annotate a single line.
The 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:
The 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.