评论#

介绍#

Python 中的注释用于在代码中添加解释或说明。它们不会影响代码的运行方式,可用于阐明逻辑、记录功能或暂时禁用部分代码。

Comments#

单行注释以 # 开头,一直持续到行尾。注释可以单独出现在一行,也可以与实际代码出现在同一行。后者称为“行内注释”。

def main():
    # This is a single-line comment
    brain.print("Hello!")  # Print a greeting message

# VR threads — Do not delete
vr_thread(main)

def main():
    # Print a greeting and then a farewell
    # in the Console
    brain.print("Hello!")
    brain.print("Goodbye!")

# VR threads — Do not delete
vr_thread(main)

Multiline String Comments#

可以使用三引号括起来的字符串注释(“”” “”” 或 ‘’’ ‘’’)进行多行解释。虽然它们本质上是字符串对象,但如果未赋值给变量,则可以作为注释使用。

def main():
    """
    This project prints a greeting message,
    followed by a farewell message in the
    Console
    """
    brain.print("Hello!")
    brain.print("Goodbye!")

# VR threads — Do not delete
vr_thread(main)