开发者

Iterating a loop with a pause

开发者 https://www.devze.com 2023-04-03 16:03 出处:网络
I am working to integrate with an API that has a limit on the number of requests per second. Is there a way, when running a for loop in python to delay each cycle? Conceptually, something like --

I am working to integrate with an API that has a limit on the number of requests per second. Is there a way, when running a for loop in python to delay each cycle? Conceptually, something like --

def function(request):
    for x in [a,b,c,d,...]:
       开发者_如何学Go do something
        wait y seconds

Thank you.


import time
...
time.sleep(5)

This will sleep for 5 seconds. See http://docs.python.org/library/time.html#time.sleep

0

精彩评论

暂无评论...
验证码 换一张
取 消