0

我写了一个从APOD下载随机图片的 python 脚本。我希望能够在 python 中指定更新频率并让 python 自动运行脚本。所以程序看起来像这样:

//first setup
print "how often should the background change in hours?"
updatefrequency = input()
schedule_autorun(updatefrequency)
//run each time
runprogram()

我已经看到人们使用 windows 任务调度程序来自动运行程序,但我想从 python 设置它。我在 Windows 7 上运行 python 2.7

4

1 回答 1

0

时间模块呢?

import time
timeinseconds = 100000
while(1):
    time.sleep(timeinseconds)
    runProgram()

如果运行程序所需的时间超过了您的等待时间,您也可以将其作为单独的进程调用。

from subprocess import call
call(['python','runProgram.py'])

或 subprocess.Popen

于 2013-07-28T04:06:46.560 回答