【问题标题】:Python FTPlib typeerror: storbinary() missing 1 required positional argument: 'fp'Python FTPlib 类型错误:storbinary() 缺少 1 个必需的位置参数:'fp'
【发布时间】:2016-05-05 23:55:42
【问题描述】:

我正在尝试将文件上传到 ftp 服务器,但它不断出现错误:TypeError: storbinary() 缺少 1 个必需的位置参数:'fp'。代码如下:

import ftplib
ftp = ftplib.FTP("Address","Username","Passcode")
print(ftp.getwelcome())
myfile=open("ftptest.txt","r")
ftp.storbinary("STOR ftptest.txt")
myfile.close()
ftp.cwd("")
ftp.quit()

您能告诉我为什么会发生错误以及任何可能的解决方案吗?

【问题讨论】:

  • 无关:以二进制模式打开文件:'rb'.

标签: python python-3.x ftp ftplib


【解决方案1】:

按照错误消息的提示传递文件对象:

ftp.storbinary("STOR ftptest.txt", myfile)

【讨论】:

    猜你喜欢
    • 2018-03-05
    • 2022-01-11
    • 1970-01-01
    • 2018-09-12
    • 2021-08-05
    • 2021-07-06
    • 2021-08-05
    • 2017-07-23
    相关资源
    最近更新 更多