Python pass是空语句,是为了保持程序结构的完整性。
passass 不做任何事情,一般用做占位语句。
范例:
# 输出 Python 的每个字母
for letter in 'Python':
if letter == 'h':
pass
print 'This is pass block'
print 'current char:', letter
print "Bye!"
结果:
current char: P
current char: y
current char: t
This is pass block
current char: h
current char: o
current char: n
<pre name="code" class="python">Bye!