发布时间:2019-08-25 09:35:04编辑:auto阅读(1622)
__author__ = 'Administrator'
# -*- coding: utf-8 -*-
#! /usr/bin/env python
#coding=utf-8
#这里需要引入三个模块
import time, os, sched,threading
# 第一个参数确定任务的时间,返回从某个特定的时间到现在经历的秒数
# 第二个参数以某种人为的方式衡量时间
schedule = sched.scheduler(time.time, time.sleep)
def perform_command(cmd, inc):
os.system(cmd)
def timming_exe(cmd, inc = 60):
# enter用来安排某事件的发生时间,从现在起第n秒开始启动
schedule.enter(inc, 0, perform_command, (cmd, inc))
schedule.enter(10, 0, perform_command, (cmd, inc))
schedule.enter(3, 0, perform_command, (cmd, inc))
# 持续运行,直到计划时间队列变成空为止
t = threading.Thread(target=schedule.run)
#schedule.run()
t.start()
print("show time after 10 seconds:")
timming_exe("echo %time%", 5)
print "next"
上一篇: [python] GIL
下一篇: 细品慢酌QuickTest关键视图(3)
49128
48269
39003
36124
30534
27332
26334
21158
21003
19343
120°
126°
222°
405°
263°
927°
958°
947°
948°
909°