Python pass 语句使用示例

yipeiwu_com6年前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自动zip压缩目录的方法

本文实例讲述了python自动zip压缩目录的方法。分享给大家供大家参考。具体实现方法如下: 这段代码来压缩数据库备份文件,没有使用python内置的zip模块,而是使用了zip.exe...

详细介绍pandas的DataFrame的append方法使用

详细介绍pandas的DataFrame的append方法使用

官方文档介绍链接:append方法介绍 DataFrame.append(other, ignore_index=False, verify_integrity=False, sort=...

详解python调度框架APScheduler使用

最近在研究python调度框架APScheduler使用的路上,那么今天也算个学习笔记吧! # coding=utf-8 """ Demonstrates how to use t...

Python读取网页内容的方法

本文实例讲述了Python读取网页内容的方法。分享给大家供大家参考。具体如下: import urllib2 #encoding = utf-8 class Crawler: d...

Python使用指定端口进行http请求的例子

使用requests库 class SourcePortAdapter(HTTPAdapter): """"Transport adapter" that allows us to...