您现在的位置是:首页 > Python2 > Python2基础之Pythonpass语句

Python2基础之Pythonpass语句

Python2作者:顾小北日期:2021-04-28点击:375

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!

下一篇       上一篇

粤ICP备20010543号