python 日期, 文件, 代码片段
#!/usr/bin/python# coding: utf-8import sysfrom datetime import *import timedef work():now = datetime.now().date()for i in range(1, 10):dateItem = now + timedelta(days=i)print
·
# 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()
更多推荐
已为社区贡献1条内容
所有评论(0)