注:
1、datetime.timedelta代表2个时间的时间差
#!/usr/bin/python
import os
import datetime
dir="/home"
now = datetime.datetime.now()
delta = datetime.timedelta(days=365)
os.chdir(dir)
for root,dirs,files in os.walk(dir):
for f in dirs:
if f == "aa":
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(root,f)))
if mtime < (now - delta):
print os.path.join(root,f)
:wq
原文地址:http://blog.51cto.com/yangzhiming/2127925