def x():
# Go through series of checks. Then in one of the conditional if statement.
if y > x:
return continue
while True:
# Bunch of class attribute updates and checks.
x()
当函数在循环中被调用时,如果达到了某些条件,则返回一个结果,使循环返回到开头,就像调用continue一样。
只需将其作为变量:
def x():
# Go through series of checks. Then in one of the conditional if statement.
if y > x:
return True
while True:
# Bunch of class attribute updates and checks.
should_continue = x()
if should_continue:
continue
创建一个返回布尔变量的函数,然后在该函数调用后使用if检查变量让我们举一个例子来说明:
你有这个功能
x(){
var check=false;
...
do something
...
if(num==5){
check=true;
}
return check;
}
你的循环一定是这样的:
while(true){
...
...
stop=x()
if(stop==false){
group of instructions you want to skip
...
...
...
}
}