異常後如何重試? - How to retry after exception?

問題:

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?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章