我想用while循环来反复执行我的脚本,但有一个问题,我的代码调用的API不允许在短时间内调用这么多,所以我想让while循环在时间间隔内执行,所以我试了一下这个代码
from threading import Timer
def myfunc():
some code
while True:
t = Timer(1.0, myfunc)
t.start()
但它不起作用,那么是否有其他正确的方法?
1 个回答
0 人赞同
Use the time module:
import time
def myfunc():
some code
while True:
myfunc()