Latest web development tutorials

ประโยคผ่านหลาม

งูหลามผ่านคำว่างในการสั่งซื้อเพื่อรักษาความสมบูรณ์ของโครงสร้างโปรแกรม

ผ่านไปโดยไม่ทำอะไรโดยทั่วไปจะใช้เป็นคำสั่งตัวยึด

ภาษา Python ไวยากรณ์คำสั่งผ่านจะเป็นดังนี้:

pass

ตัวอย่าง:

#!/usr/bin/python
# -*- coding: UTF-8 -*- 

# 输出 Python 的每个字母
for letter in 'Python':
   if letter == 'h':
      pass
      print '这是 pass 块'
   print '当前字母 :', letter

print "Good bye!"

ผลที่ได้จากตัวอย่างข้างต้น:

当前字母 : P
当前字母 : y
当前字母 : t
这是 pass 块
当前字母 : h
当前字母 : o
当前字母 : n
Good bye!