问题:
I have a loop starting with for i in range(0, 100)
.我有一个以for i in range(0, 100)
开头的循环。 Normally it runs correctly, but sometimes it fails due to network conditions.通常它运行正常,但有时会由于网络条件而失败。 Currently I have it set so that on failure, it will continue
in the except clause (continue on to the next number for i
).目前我已经设置了它,以便在失败时,它将continue
在 except 子句中(继续到i
的下一个数字)。
Is it possible for me to reassign the same number to i
and run through the failed iteration of the loop again?我是否可以将相同的数字重新分配给i
并再次运行失败的循环迭代?
解决方案:
参考一: https://stackoom.com/question/8k8h参考二: How to retry after exception?