Python 学习:今天写了一个简单的定时任务
今天有一个很简单的需求,要求定时执行一个 .bat 批处理文件。于是查看了一下 Python 文档,写出如下脚本:
from win32api import *
from time import *
i = 1
while 1:
ShellExecute(0, None, "c:\\test.bat", None, "c:\\", True)
print "The job has been executed", i, "times till now."
i += 1
sleep(10 * 60)
from time import *
i = 1
while 1:
ShellExecute(0, None, "c:\\test.bat", None, "c:\\", True)
print "The job has been executed", i, "times till now."
i += 1
sleep(10 * 60)