码迷,mamicode.com
首页 > 其他好文 > 详细

pass语句

时间:2017-03-02 23:22:48      阅读:493      评论:0      收藏:0      [点我收藏+]

标签:logs   nbsp   span   div   something   何事   完整性   utf-8   print   

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!

 

C/C++中写法:
if(true)
; // do nothing
else
{} // do nothing

Python中写法:
if true:
pass # do nothing
else:
print “do something.”

 

pass语句

标签:logs   nbsp   span   div   something   何事   完整性   utf-8   print   

原文地址:http://www.cnblogs.com/ymjyqsx/p/6492758.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!