FTP retrbinary为什么下载不了

FTP retrbinary为什么下载不了

from ftplib import FTP
ftp = FTP('172.40.66.214')
ftp.login('edi','vsagentlib')
ftp.cwd('update')
ftp.retrbinary('Publica_xls.pbd', open('Publica_xls.pbd', 'wb').write)
lfile = []

ftp.dir(lfile.append)
ftp.close()
print lfile

下面是错误
Traceback (most recent call last):
  File "C:\Python24\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "C:\image\ftptst.py", line 5, in ?
    ftp.retrbinary('Publica_xls.pbd', open('Publica_xls.pbd', 'wb').write)
  File "C:\Python24\lib\ftplib.py", line 379, in retrbinary
    conn = self.transfercmd(cmd, rest)
  File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python24\lib\ftplib.py", line 327, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:\Python24\lib\ftplib.py", line 216, in getresp
    raise error_perm, resp
error_perm: 500 'PUBLICA_XLS.PBD': command not understood.
把ftp.retrbinary('Publica_xls.pbd', open('Publica_xls.pbd', 'wb').write)
改为ftp.retrbinary('RETR', open('Publica_xls.pbd', 'wb').write,204


QUOTE:
原帖由 ragkk 于 2007-1-18 22:10 发表
把ftp.retrbinary('Publica_xls.pbd', open('Publica_xls.pbd', 'wb').write)
改为ftp.retrbinary('RETR', open('Publica_xls.pbd', 'wb').write,204

exec codeObject in __main__.__dict__
  File "C:\image\ftptst.py", line 10, in ?
    ftp.retrbinary('resp', file_handler ,bufsize)
  File "C:\Python24\lib\ftplib.py", line 379, in retrbinary
    conn = self.transfercmd(cmd, rest)
  File "C:\Python24\lib\ftplib.py", line 345, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "C:\Python24\lib\ftplib.py", line 327, in ntransfercmd
    resp = self.sendcmd(cmd)
  File "C:\Python24\lib\ftplib.py", line 241, in sendcmd
    return self.getresp()
  File "C:\Python24\lib\ftplib.py", line 216, in getresp
    raise error_perm, resp
error_perm: 500 'RESP': command not understood.


QUOTE:
原帖由 ragkk 于 2007-1-18 22:10 发表
把ftp.retrbinary('Publica_xls.pbd', open('Publica_xls.pbd', 'wb').write)
改为ftp.retrbinary('RETR', open('Publica_xls.pbd', 'wb').write,204

以下可以正确下载

ftp.retrbinary('RETR vsla_dw.pbd', open('vsla_dw.pbd', 'wb').write)

RETR 后面跟的是要下载的文件
跟着学,