-4
我在一個python腳本中使用你的ftputil來獲取目錄中文件的最後修改/創建日期,我幾乎沒有問題,並想知道你是否可以提供幫助。我在一個python腳本中使用你的ftputil
host.stat_cache.resize(200000)
recursive = host.walk(directory, topdown=True, onerror=None)
for root,dirs,files in recursive:
for name in files:
#mctime = host.stat(name).mtime
print name
以上輸出的所有文件的目錄
host.stat_cache.resize(200000)
recursive = host.walk(directory, topdown=True, onerror=None)
for root,dirs,files in recursive:
for name in files:
if host.path.isfile("name"):
mtime1 = host.stat("name")
mtime2 = host.stat("name").mtime
#if crtime < now -30 * 86400:
#print name + " Was Created " + " " + crtime + " " + mtime
print name + " Was Created " + " " + " " + mtime1 + " " + mtime2
上面的列表不產生輸出
誰是「你的」這裏指的是?同樣,從代碼中可以看出,如果'files'或'recursive'是空的,或者每個文件的'isfile'檢查都失敗了,你就不會輸出。嘗試在循環之前添加一個「打印文件」和「打印遞歸」。 – Daenyth
遞歸= host.walk(目錄,自上而下=真,的onerror =無) 用於遞歸根,顯示目錄,文件: 進行名稱在文件: #mctime = host.stat(名)以上.mtime 打印名 – Echo
產生一個遞歸的文件列表,文件包含一些東西 – Echo