相关疑难解决方法(0)

如何从FTP服务器删除超过7天的Python脚本文件?

我想写一个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 file delete-file

9
推荐指数
2
解决办法
2万
查看次数

使用 Python 列出 FTP 中所有子目录中的所有文件

我是 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']我的输出。我已经尝试并查找了很多以找到解决方案/提示来执行此操作。

python ftp ftplib subdirectory filelist

6
推荐指数
1
解决办法
7351
查看次数

标签 统计

ftp ×2

python ×2

delete-file ×1

file ×1

filelist ×1

ftplib ×1

subdirectory ×1