【问题标题】:Delete file on ftp server with pycurl使用 pycurl 删除 ftp 服务器上的文件
【发布时间】:2020-07-31 08:20:18
【问题描述】:

是否可以在 python 中使用 pycurl-lib 删除 ftp 服务器上的文件?

到目前为止,我的代码无法正常工作,它会抛出:(21, 'QUOT command failed with 550')

    c = pycurl.Curl()
    c.setopt(pycurl.URL, 'ftp://ftpadress/testdirectory')
    c.setopt(pycurl.USERPWD, 'user:pass')
    c.setopt(pycurl.QUOTE, ['DELE test.txt'])
    c.perform()
    c.close()

【问题讨论】:

  • 如果Curl真的剥离了服务器发出的550代码的实际错误信息,检查日志文件看看。 + 您是否尝试使用 GUI/命令行 FTP 客户端删除文件?
  • 设置VERBOSE查看完整交互...

标签: python ftp libcurl pycurl


【解决方案1】:

它可以将“DELE test.txt”从基础更改为完整路径。 喜欢:

    c = pycurl.Curl()
    c.setopt(pycurl.URL, 'ftp://ftpadress')
    c.setopt(pycurl.USERPWD, 'user:pass')
    c.setopt(pycurl.QUOTE, ['DELE testdirectory/test.txt'])
    c.perform()
    c.close()

【讨论】: