python ftplib 用户权限_高级Python FTP - 我可以控制ftplib如何与服务器通话吗?

尝试以下操作。它是原始FTP.dir命令的修改,它使用“dir”而不是“LIST”。它给我测试过的ftp服务器提供了一个“DIR未知”的错误,但它确实发送了你之后的命令。 (您将要删除我用来检查的打印命令。)

import ftplib

class FTP(ftplib.FTP):

def shim_dir(self, *args):

'''List a directory in long form.

By default list current directory to stdout.

Optional last argument is callback function; all

non-empty arguments before it are concatenated to the

LIST command. (This *should* only be used for a pathname.)'''

cmd = 'dir'

func = None

if args[-1:] and type(args[-1]) != type(''):

args, func = args[:-1], args[-1]

for arg in args:

if arg:

cmd = cmd + (' ' + arg)

print cmd

self.retrlines(cmd, func)

if __name__ == '__main__':

f = FTP('ftp.ncbi.nih.gov')

f.login()

f.shim_dir('"blast"')

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值