Home > Backend Development > Python Tutorial > What is the function of pass statement in Python statement? A brief discussion on the usage of pass statement

What is the function of pass statement in Python statement? A brief discussion on the usage of pass statement

Tomorin
Release: 2018-08-13 17:01:29
Original
5094 people have browsed it

The

pass statement is like 0 in mathematics. itself has no practical meaning, but it is a character that does exist. So, Python pass statement is an empty statement to maintain the integrity of the program structure. pass does not do anything and is generally used as a placeholder statement, has the same effect as break, but has completely opposite meaning.

The Python language pass statement syntax format is as follows:

pass
Copy after login

Example:

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

The above example execution results:

Current letter: P
Current letter: y
Current letter: t
This is the pass block
Current letter: h
Current letters: o
Current letters: n
Good bye!


These are python Article on the control statement of the loop statement:

The usage and function of the continue statement of the Python statement

Python The break statement in the statement jumps out of the loop instance


The above is the detailed content of What is the function of pass statement in Python statement? A brief discussion on the usage of pass statement. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template