python:pass

版权声明:本文为博主原创文章,未经博主允许欢迎转载。 https://blog.csdn.net/paulkg12/article/details/87801037

Python pass 是空语句,是为了保持程序结构的完整性。

pass 不做任何事情,一般用做占位语句。

eg

#!/usr/bin/python
# -*- coding: UTF-8 -*- 
 
# 输出 Python 的每个字母
for letter in 'Python':
   if letter == 'h':
      pass
      print '这是 pass 块'
   print '当前字母 :', letter
 
print "Good bye!"

output:

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

猜你喜欢

转载自blog.csdn.net/paulkg12/article/details/87801037