python timer使用-python 定时器使用

#!/usr/bin/python

# -*- coding:utf-8 -*-

import datetime,os,platform,time

def run_Task():

import SendMail

SendMail.SendMail()

#os_platform=platform.platform()

##if os_platform.startswith("Darwin"):

#print "this is mac os system!"

#os.system("ls")

#elif os_platform.startswith("Linux"):

#print "this is Linux system!"

#os.system("ls")

def timerFun(sched_Timer):

flag = 0

#now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

while True:

now = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")

#print now,sched_Timer

if now == str(sched_Timer):

print "*"*30

run_Task()

flag = 1

time.sleep(60)

#break

else:

if flag==1:

sched_Timer=sched_Timer+datetime.timedelta(days=1)

flag=0

if __name__ =="__main__":

sched_Timer = datetime.datetime(2018,5,8,9,0,0)

print "run the timer task at{0}".format(sched_Timer)

timerFun(sched_Timer)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值