Python 等价于 setInterval()? [英] Python Equivalent of setInterval()?

查看:53
本文介绍了Python 等价于 setInterval()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Python 有类似 JavaScript 的 setInterval() 的功能吗?

Does Python have a function similar to JavaScript's setInterval()?

谢谢

推荐答案

这可能是您正在寻找的正确片段:

This might be the correct snippet you were looking for:

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

这篇关于Python 等价于 setInterval()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆