2014-09-19 73 views
0

我想使用ftplib和python上傳文件。我繼續得到這個錯誤,不知道爲什麼...幫助?無法打開通過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() 

回答

0

該錯誤意味着你沒有權限上傳文件。

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

host真的是你的意思嗎?