python 中的 Goto 语句 - 还有什么其他方法?

Goto statement in python - what other way is there?

我的程序有以下结构

  1. 程序截图 2、程序查找条件 a.如果不满足条件a,则需要回到1
  2. 程序寻找条件 b。如果不满足条件b,则需要返回到点1
  3. 程序寻找条件c。如果不满足条件c,则需要回到第1点 ...等等

大约有 20 个附加条件,只要其中一个条件不满足,程序就应该 return 到起点。使用 goto 语句可以很容易地解决这个问题。但是,在 Python 中,这不是一个选项。如有任何建议可以优雅地实施,我们将不胜感激。

你应该给我们代码,或者至少给我们一个例子来说明结构的真实情况。

也许你可以这样做:

take screenshot
condition = (condition a) and (condition b) and ... and (condition z)

while (not condition):
    take screenshot
    condition = (condition a) and (condition b) and ... and (condition z)