Python pass 语句使用示例

yipeiwu_com5年前Python基础

Python pass是空语句,pass语句什么也不做,一般作为占位符或者创建占位程序,是为了保持程序结构的完整性,pass语句不会执行任何操作,比如:

Python 语言 pass 语句语法格式如下:

复制代码 代码如下:
pass

复制代码 代码如下:
实例:

复制代码 代码如下:

#!/usr/bin/python

for letter in 'Python':
   if letter == 'h':
      pass
      print 'This is pass block'
   print 'Current Letter :', letter

print "Good bye!"


以上实例执行结果:
复制代码 代码如下:

Current Letter : P
Current Letter : y
Current Letter : t
This is pass block
Current Letter : h
Current Letter : o
Current Letter : n
Good bye!

相关文章

使用Python的Twisted框架编写非阻塞程序的代码示例

先来看一段代码: # ~*~ Twisted - A Python tale ~*~ from time import sleep # Hello, I'm a develop...

深入理解Python中的*重复运算符

在python中有个特殊的符号“*”,可以用做数值运算的乘法算子,也是用作对象的重复算子,但在作为重复算子使用时一定要注意 注意的是:*重复出来的各对象具有同一个id,也就是指向在内存...

PyCharm专业最新版2019.1安装步骤(含激活码)

PyCharm专业最新版2019.1安装步骤(含激活码)

Pycharm是一款很好用的python开发工具,开发Python爬虫和Python web方面都很不错 这里我为大家提供了两种pycharm激活方式 分别为:2020年、2089年、...

pip install urllib2不能安装的解决方法

python35 urllib2 不能用 Could not find a version that satisfies the requirement urllib2 (from...

python下调用pytesseract识别某网站验证码的实现方法

一、pytesseract介绍 1、pytesseract说明 pytesseract最新版本0.1.6,网址:https://pypi.python.org/pypi/pytesser...