我如何在特定时间后每隔 30 分钟安排一次 Python 代码
我有一个时间 - “09:20:45” 我想在这个时间的每 30 分钟之后安排我的代码 - “09:20:45”。
我不知道我该怎么做?
schedule.every(30).minutes.do(output_file_exporting)
while True:
schedule.run_pending()
time.sleep(1)
其中 output_file_exporting
是我的函数名称。
所以我想在 09:20:45 之后以每 30 分钟的增量运行我的代码 就像-
09:50:45
10:20:45
10:50:45
11:20:45
11:50:45
在这些时候我的代码应该运行。
I have a time - "09:20:45"
And I want to schedule my code after every 30 minutes of this time - "09:20:45".
I don't know how can I do this?
schedule.every(30).minutes.do(output_file_exporting)
while True:
schedule.run_pending()
time.sleep(1)
where output_file_exporting
is my function name.
So I want to run my code after 09:20:45 on the increment of every 30 minutes
like -
09:50:45
10:20:45
10:50:45
11:20:45
11:50:45
on these time my code should be run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你让事情变得比需要的更加困难。你只要按照你描述的那样去做就可以了。
You're making this harder than it needs to be. You just do it like you describe it.