注释#
简介#
Python 中的注释用于在代码中添加解释或说明。它们不会影响代码的运行,并且有助于阐明逻辑、记录功能或暂时禁用部分代码。
Comments#
A single-line comment starts with # and continues until the end of the line. Comments can appear on a line alone, or on the same line as actual code. These are called “inline comments.”
# This is a single-line comment
print("Hello!") # Print a greeting message
# Print a greeting and then a farewell
# in the Console
print("Hello!")
print("Goodbye!")
Multiline String Comments#
三引号字符串注释(“”” “”” 或 ‘’’ ‘’’)可用于多行解释。虽然它们是字符串对象,但如果不分配给变量,它们可以用作注释。
"""
This project prints a greeting message,
followed by a farewell message in the
Console.
"""
print("Hello!")
print("Goodbye!")