if conditional statement if <test1>: can be nested <statements1> elif <test2>: can be omitted <statements2> else : Optional: Optional <statements3> The ternary expression A=Y if X else Z executes expression Y when X is true, and executes expression Z when X is false Equivalent to A=X and Y or Z while循环 while <test>: <statements1> else : Optional: Optional <statements2> for循环 for <target> in <object>: <statements> else : Optional: Optional <statements> break : jump out of the most recent loop continue : jump to the beginning of the most recent loop and execute the next loop pass : do nothing, just an empty station statement, can also be used after python3.0 ... instead The loop else is fast: it will only be executed when the loop leaves normally (that is, no break statement is encountered)
Python flow control statement structure summary
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=325999965&siteId=291194637
Ranking