What is the pass statement in Python? Indicates that it does nothing and is generally used as a placeholder statement. Pass statement the specific role and use of the method, we look down.
The function of PASS statements in functions
When you are writing a program, the execution of the statement part of the idea is not complete, you can use the PASS statement to occupy a bit, can also be used as a token, is to be completed after the code. such as the following:
>>>def Iplaypython ():
>>> Pass
A function iplaypython is defined, but the function body part is not finished yet, and cannot be empty without writing the content, so it is possible to replace the position with a pass.
The function of the pass statement in the loop
Pass is also often used to write an empty body for a compound statement, for example, you want an infinite loop of a while statement, no action is required for each iteration, you can write:
>>>while True:
>>> Pass
Just for example, in reality it is best not to write this code, because the code block for the pass is the empty do nothing, then Python will enter the dead loop.
Summary of usage of pass statement
1, empty statement, do nothing
2, in special time to ensure the integrity of the format or semantics
Python Pass statement function and usage