我想写一个Python脚本,它允许我在达到一定年龄后从FTP服务器中删除文件.我准备了下面的scipt但它抛出了错误消息:WindowsError: [Error 3] The system cannot find the path specified: '/test123/*.*'
有人知道如何解决这个问题吗?先感谢您!
import os, time
from ftplib import FTP
ftp = FTP('127.0.0.1')
print "Automated FTP Maintainance"
print 'Logging in.'
ftp.login('admin', 'admin')
# This is the directory that we want to go to
path = 'test123'
print 'Changing to:' + path
ftp.cwd(path)
files = ftp.retrlines('LIST')
print 'List of Files:' + files
#--everything works fine until here!...
#--The Logic which shall delete the files after the are 7 days old--
now …Run Code Online (Sandbox Code Playgroud) 我是 Python 新手,我正在尝试列出 FTP 中所有子目录中的所有文件。FTP 和往常一样,就是这种格式。
A
B
C
Run Code Online (Sandbox Code Playgroud)
子目录:
AA
BB
CC
Run Code Online (Sandbox Code Playgroud)
['A', 'B', 'C']我可以使用列出目录ftp.nlist()。我想得到['AA', 'BB', 'CC']我的输出。我已经尝试并查找了很多以找到解决方案/提示来执行此操作。