[英]Is there a rich ftp client library for Python?
I'm familiar with ftplib and it works great for simple interface but I need file properties and basically a rich ftp client.我熟悉 ftplib,它适用于简单的界面,但我需要文件属性,基本上是一个丰富的 ftp 客户端。 does anyone know of a good ftp client library?
有人知道一个好的 ftp 客户端库吗?
Use the MLSD command.使用 MLSD 命令。 You have to parse it yourself but it's fairly easy.
你必须自己解析它,但这很容易。
# Note that portions of MLSD data are case insensitive...
def parseinfo(info):
for fact in info.split(';'):
if not fact:
continue
name, value = fact.split('=', 1)
yield name.lower(), value
ftp = ftplib.FTP(host, user, passwd)
dirinfo = {}
def callback(line):
info, fname = line.split(' ', 1)
dirinfo[fname] = dict(parseinfo(info))
ftp.retrlines('MLSD {}'.format(path), callback)
print(dirinfo)
That's about as rich as FTP gets.这大约和 FTP 一样丰富。
The ftputil could be what you are looking for: ftputil可能是您正在寻找的:
The FTPHost objects generated with ftputil allow many operations similar to those of os and os.path.
使用 ftputil 生成的 FTPHost 对象允许许多类似于 os 和 os.path 的操作。
The API supports well file information gathering . API 支持井文件信息收集。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.