Python pass是空语句,是为了保持程序结构的完整性。
pass不做任何事情,一般用作占位语句。
Python语言pass语句语法格式如下:
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!