我想告诉python脚本在某个时间戳发生时运行某个函数
我已经寻找了运行时特定的函数 但我找不到任何东西来回答这个具体的问题 计算时间戳
#input is number of days till due date
dueDate = int(input('Days until it is due: '))
#86400 seconds in a day
days = dueDate * 86400
#gets current time stamp time
currentT = int(time.time())
#gets the timestamp for due date
alarm = days+currentT
目标是找到python函数,当指定的未来时间戳出现时,该函数可以从脚本中运行另一个函数
你可以把剧本睡那么久。你知道吗
资料来源:python docs
Schedule是一个很好的python模块。你知道吗
用法:(来自文档)
安装
用法
内置到python中的是
sched
模块。Here是一篇非常好的文章,而here是官方文档。使用scheduler.enter
可以延迟调度,使用scheduler.enterabs
可以调度特定的时间。你知道吗输出:
相关问题 更多 >
编程相关推荐