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

วิธีสร้าง Multi-line Comments ใน Python

Comment ใน Python เริ่มด้วย # จบที่สิ้นบรรทัด ไม่มี block comment แบบ C (/* ... */)

คอมเมนต์หลายบรรทัด ให้วาง # นำหน้าทุกบรรทัด:

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

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

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