这是列出来自 FTP 服务器的所有子目录的代码。如何搜索位于这些多个子目录目录中的最新 Excel 文件?如结果所示,我想遍历所有ls****
子目录并通知我是否有今天日期的 Excel 文件。
提前致谢!
from ftplib import FTP
def handleDownload(block):
file.write(block)
print ".",
ftp = FTP('connect to host,'name', 'dflt port')
directory = 'Dir_name'
ftp.cwd(directory)
data = []
ftp.dir(data.append)
ftpContentList = ftp.retrlines('LIST') # list directory contents
结果:
drwxrwx--- 4 17610000 smartfile 4096 Jul 21 19:31 ls0125
drwxrwx--- 4 17610000 smartfile 4096 Jul 19 20:34 ls0146
drwxrwx--- 4 17610000 smartfile 4096 Jul 21 19:31 ls0265
drwxrwx--- 4 17610000 smartfile 4096 Jul 19 20:34 ls0368