如何在给定时间在Python中运行函数?
例如:
run_it_at(func, '2012-07-17 15:50:00')
Run Code Online (Sandbox Code Playgroud)
它将func在2012-07-17 15:50:00 运行该功能.
我尝试了sched.scheduler,但它没有启动我的功能.
import time as time_module
scheduler = sched.scheduler(time_module.time, time_module.sleep)
t = time_module.strptime('2012-07-17 15:50:00', '%Y-%m-%d %H:%M:%S')
t = time_module.mktime(t)
scheduler_e = scheduler.enterabs(t, 1, self.update, ())
Run Code Online (Sandbox Code Playgroud)
我能做什么?
我想写一个简单的python脚本来完成一项特定的工作.我从网站上得到一些时间和链接信息.
times=
[
('17.04.2011', '06:41:44', 'abc.php?xxx'),
('17.04.2011', '07:21:31', 'abc.php?yyy'),
('17.04.2011', '07:33:04', 'abc.php?zzz'),
('17.04.2011', '07:41:23', 'abc.php?www'),]
Run Code Online (Sandbox Code Playgroud)
在合适的时间点击这些链接的最佳方式是什么?我是否需要计算当前列表和列表中的时间间隔并暂停一段时间?
我现在真的陷入困境,对任何可能有用的想法持开放态度.