小编Tom*_*Tom的帖子

如何从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万
查看次数

标签 统计

delete-file ×1

file ×1

ftp ×1

python ×1