The while loop, as was the case with the if statement, supports an optional else clause containing a block of program statements executed when the expression is False.
while循环与if语句一样,支持一个可选的else子句,其中包含一个当表达式计算为False时执行的程序语句块。
For a while loop, however, this means the code in the else clause is executed once, after the loop is terminated (see the pseudocode shown in Listing 7).
但是对于while循环,这意味着在循环终止后,else子句中的代码被执行一次(参见清单7中的伪代码)。
The expression used in the if statement (and in the elif clause and the while loop discussed later in this article) can be as complex as necessary.
if语句(以及本文后面讨论的elif子句和while循环)中的表达式可以很复杂。
应用推荐