【问题标题】:Getting "500 Unknown command" when uploading a file to FTP in Python with FTP.storbinary使用 FTP.storbinary 在 Python 中将文件上传到 FTP 时出现“500 Unknown command”
【发布时间】:2017-09-08 07:57:04
【问题描述】:

我正在尝试将文件上传到 FTP。我正在尝试在files.000webhost.com 上将文件上传到/public_html,但我不断收到ftplib.error_perm: 500 Unknown command

我的代码如下:

import ftplib
session = ftplib.FTP('files.000webhost.com','hazaaay','dwadawdadw')
file = r'C:\\Users\\Downloads\\A csv\\a csv1.csv','b'                  # file to send
session.storbinary('a csv1.csv', file)     # send the file
file.close()                                    # close file and FTP
session.quit()

尽管给出了未解决的参考,但它在控制台中说进程以退出代码 0 结束,尽管它没有出现在 FileZilla 中。有任何想法吗? 谢谢。

【问题讨论】:

    标签: python python-3.x ftp ftplib


    【解决方案1】:

    您必须在FTP.storbinary call 中指定命令。

    以二进制传输模式存储文件。 command 应该是适当的STOR 命令:"STOR filename"

    session.storbinary('STOR a csv1.csv', file)  
    

    【讨论】:

    • 感谢您的帮助:)
    猜你喜欢
    • 2021-11-04
    • 2016-05-31
    • 2018-09-06
    • 1970-01-01
    • 2013-07-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    相关资源
    最近更新 更多