Python 多线程定时器 一次 timer 只生效一次,不会反复循环,如果实现循环触发,代码如下: 123456789101112import timeimport threadingdef createTimer(): t = threading.Timer(2, repeat) t.start() def repeat(): print('Now:', time.strftime('%H:%M:%S',time.localtime())) createTimer() createTimer() 这段代码的功能就是每 2 秒打印出当前的时间,即一个 2 秒的定时器。 随笔 #Python Python 多线程定时器 https://wonderhoi.com/2025/03/25/Python-多线程定时器/ 作者 wonderhoi 发布于 2025年3月25日 许可协议 SSH 出现警告 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED 上一篇 Python 判断数组是否为空 下一篇