這是功能我正在使用Python來刪除舊迪爾斯需要使用Python幫助刪除舊迪爾斯腳本
def delete_olddirs(days,file_path):
numdays = 60*60*24*days
now = time.time()
for dir in os.listdir(file_path):
r = file_path
timestamp = os.path.getmtime(os.path.join(r,dir))
if now-numdays > timestamp:
try:
print "removing ",os.path.join(r,dir)
#shutil.rmtree(os.path.join(r,dir)) #uncomment to use
except Exception,e:
print e
pass
else:
print "some message for success"
的問題是,每次我看到消息removing . ....
我也看到消息
some message for success
我想知道爲什麼每次都執行部件
明白了,謝謝 – user2134226 2011-05-26 16:09:32