評論#

介紹#

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)