我在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
上面没有输出
答案 0 :(得分:1)
您已将name
放入引号中。因此Python将始终检查文字文件名“name”,这可能不存在。你的意思是:
if host.path.isfile(name):
mtime1 = host.stat(name)
mtime2 = host.stat(name).mtime