# coding: utf-8
import sys
from datetime import *
import time
import os
import shutil

def work():
    mapDirDel= {}
    now = datetime.now().date()
    for i in range(1, 10):
     dateItem = now - timedelta(days=i + 0)
     dateStr = dateItem.strftime("%Y-%m-%d")
     mapDirDel[dateStr]=dateStr

    print mapDirDel
    dir = '/home/data'
    for s in os.listdir(dir):
      if mapDirDel.has_key(s):
        print 'to del ',dir+s
        shutil.rmtree(dir+s)


if __name__=='__main__':
  work()
Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐