Single-line Comments
In Python, single-line comments start with #, for example:
# This is a single-line comment
print("hello")
Multi-line Comments
Multi-line comments are enclosed with three single quotes ”’ or three double quotes “””, for example:
1. Single Quotes (”’)
'''This is a multi-line comment, using three single quotes
This is a multi-line comment, using three single quotes
This is a multi-line comment, using three single quotes'''print("Hello!")
2. Double Quotes (“””)
"""This is a multi-line comment, using three double quotes
This is a multi-line comment, using three double quotes
This is a multi-line comment, using three double quotes"""print("Hello, World!")
Note:
When the Python interpreter encounters a # comment, it will automatically skip it.
However, when it encounters a ”’ quote comment, it will load it into memory.
Because the essence of quote comments is that they define a string.
It’s just that this string is not being used.