如何在“for i in range”回圈中暫停,例如在 100 次呼叫之后?
我有這部分代碼:
with open(r'url\url.txt', encoding='utf8') as f:
for i in range(total_urls):
現在我想在 100 次通話后暫停一下。
我發現的只是在通話之間做time.sleep()或設定隨機暫停,但這不是我需要的。我在通話之間已經有 10 秒的暫停,但在 100 次通話后我需要暫停更長的時間。
uj5u.com熱心網友回復:
像這樣?
with open(r'url\url.txt', encoding='utf8') as f:
for i in range(total_urls):
if i > 0 and i % 100 == 0:
time.sleep(100)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/519793.html
標籤:Python循环暂停
