当循环和For循环在一起时[关闭]

问题描述 投票:-1回答:1

嗨,我想运行使循环无限运行。

例如

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
python for-loop while-loop infinite-loop do-loops
1个回答
0
投票

我猜你是想运行一个程序,即使有一个异常,并在某些条件下打破,你不想运行循环无限的我想。

While true:
    try:
        for symbol in symbols:
            script(symbol) ' you should break however somewhere
    Exception as e:
        continue
© www.soinside.com 2019 - 2024. All rights reserved.