Python 时间延迟

标签 python time

我想知道如何在一段时间后调用函数。我试过 time.sleep() 但这会停止整个脚本。我希望脚本继续运行,但在 ???secs 后调用一个函数并同时运行另一个脚本

最佳答案

看看threading.Timer .它在新线程中运行您的函数。

from threading import Timer

def hello():
    print "hello, world"

t = Timer(30.0, hello)
t.start() # after 30 seconds, "hello, world" will be printed

关于Python 时间延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3433559/

相关文章:

python - 将 fortran double 格式读入 python

javascript - 自页面加载后的 JQuery Clock/Timer(即使用户更改其计算机上的时间)

linux - CodeIgniter 日历日期显示 - 显示生产提前一天

java - Android 使用真正的 unix 时间

python - 根据时间戳中存在的两列中的元素分隔行

python - 如何自动化 AWS s3 存储桶对象的权限

python - 无法使用 python 和 beautifulsoup 抓取网页中的某些 href

python - Pytest + 多处理队列不能很好地协同工作

javascript - 如何使用 Javascript 在下拉列表中显示时间表?

C#如何实现带时间步长的循环