Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Python pass statement


May 10, 2021 Python2


Table of contents


Python pass statement

Python pass is an empty statement to maintain the integrity of the program structure.

Pass does nothing and is generally used as a placeholder statement.

The Python language pass statement syntax format is as follows:

pass

Instance:

# -*- coding: UTF-8 -*- 
#!/usr/bin/python

# 输出 Python 的每个字母
for letter in 'Python':
   if letter == 'h':
      pass
      print '这是 pass 块'
   print '当前字母 :', letter

print "Good bye!"

The results of the above example execution:

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