Equivalent of setInterval in python

前端 未结 4 1758
予麋鹿
予麋鹿 2020-12-13 10:21

I have recently posted a question about how to postpone execution of a function in Python (kind of equivalent to Javascript setTimeout) and it turns out to be a

4条回答
  •  独厮守ぢ
    2020-12-13 11:09

    Maybe these are the easiest setInterval equivalent in python:

     import threading
    
     def set_interval(func, sec):
        def func_wrapper():
            set_interval(func, sec) 
            func()  
        t = threading.Timer(sec, func_wrapper)
        t.start()
        return t
    

提交回复
热议问题