在python上安排任务 [英] Scheduling a task on python
本文介绍了在python上安排任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想运行一个每 4 小时运行一次函数的程序.这样做的消耗最少的方法是什么?
I want to run a program that runs a function every 4 hours. What is the least consuming way to do so?
推荐答案
我能想到的最简单的方法(在 python 中,因为帖子是用 python 标记的):
Simlest way I can think of (in python since the post is tagged with python):
import time
while True:
do_task()
time.sleep(4 * 60 * 60) # 4 hours * 60 minutes * 60 seconds
这篇关于在python上安排任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文