python实用的程序(周期执行)

#! /usr/bin/env python
#coding=utf-8
# 以需要的时间间隔执行某个命令  

import time, os
import datetime

#计算今天的时间
today = datetime.date.today()

def re_exe(cmd, inc = 1):
        os.system(cmd)
        time.sleep(inc)
        
for i in range(1,12):
    print i
    yesterday = today - datetime.timedelta(days = i)
    stryes=yesterday.strftime('%Y-%m-%d')
    cmd = 'python 3g_club_shouye_redoman_pv.py \''+stryes+'\''
    re_exe(cmd,60)

你可能感兴趣的:(python,周期执行)