Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีเขียน Comments ใน Python

Comment คือข้อความอธิบายโค้ด ถูก interpreter ข้าม เริ่มด้วย # จบสิ้นบรรทัด

# this is a comment
print("Hello World")
print("Welcome to TutorialsPoint")  # this is also a comment after statement

Python ไม่มี multi-line comment block ต้องวาง # ทุกบรรทัด IDE หลายตัวมี shortcut comment block

Triple-quoted string ถือเป็น comment ได้ ถ้าไม่ใช่ docstring:

'''
comment1
comment2
comment3
'''
print("Hello World")