无法通过FTPLIB和Python打开文件错误上传文件

时间:2014-09-19 14:14:49

标签: python ftp ftplib

我正在尝试使用ftplib和python上传文件。我继续收到此错误并且不知道为什么......帮助?

Traceback (most recent call last):
  File "C:\Users\212392169\Desktop\ftp_trial.py", line 15, in <module>
    ftp.storbinary("STOR samplee.bin", f)
  File "C:\Python27\lib\ftplib.py", line 471, in storbinary
    conn = self.transfercmd(cmd, rest)
  File "C:\Python27\lib\ftplib.py", line 376, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python27\lib\ftplib.py", line 339, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python27\lib\ftplib.py", line 249, in sendcmd
    return self.getresp()
  File "C:\Python27\lib\ftplib.py", line 224, in getresp
    raise error_perm, resp
    ftplib.error_perm: 550 Can't open file "samplee.bin"

源代码:

from ftplib import FTP    
ftp = FTP(host)

ftp.login(host,pw)    
ftp.cwd("/dflts")

f = open('samplee.bin', 'rb')
ftp.storbinary("STOR samplee.bin", f)
f.close()
ftp.quit()

1 个答案:

答案 0 :(得分:0)

该错误表示您无权上传文件。

ftp.login(host, pw)
          ^^^^

host真的是你的意思吗?