While循环和For循环一起

时间:2020-05-02 20:49:41

标签: python for-loop while-loop infinite-loop do-loops

嗨,我想让make for循环无限运行。

例如。

while True:

    try:
     script()

except Exception as e:
        script()
        continue

如下所示,因为在For循环中,我列出了要应用于按顺序和连续方式运行的脚本

while True:
    try:
        for symbol in symbol:
            script()

    except Exception as e:
        for symbol in symbol:
            script()
        continue

1 个答案:

答案 0 :(得分:0)

我想您即使在有异常并在某些情况下中断的情况下,也正在尝试运行程序,但我不想无限运行循环。你可以做

While true:
    try:
        for symbol in symbols:
            script(symbol) ' you should break however somewhere
    Exception as e:
        continue