【发布时间】:2011-09-03 15:22:12
【问题描述】:
如果由于某种原因我想重复相同的迭代,我该如何在 python 中做到这一点?
for eachId in listOfIds:
#assume here that eachId conatins 10
response = makeRequest(eachId) #assume that makeRequest function request to a url by using this id
if response == 'market is closed':
time.sleep(24*60*60) #sleep for one day
现在,当函数在一天后从睡眠中唤醒时(市场(货币交易市场)打开)我想从 eachId = 11 恢复我的 for 循环,因为 eachId = 10 还没有已作为market was closed 处理,非常感谢任何帮助。
【问题讨论】:
-
将内容保存到列表中。
-
我认为他要问的是如何在一次迭代中不增加
for循环列表计数器。