ftplib.error_perm: 500 Unknown command.

from ftplib import FTP


def ftpconnect():
    ftp_server = 'xxxxxxxxx'
    username = 'xxxxxxxxxx'
    password = 'xxxxxxxxxxxx'
    ftp = FTP()
    ftp.set_debuglevel(2)
    ftp.connect(ftp_server, 21)
    ftp.login(username, password)
    return ftp


def downloadfile(time = '20200521', filename = '20052108.000'):
    remotepath = time + '\\GRAPES_3KM\\TMP\\2M_ABOVE_GROUND\\'
    ftp = ftpconnect()
    print(ftp.getwelcome())
    localpath = 'D:\\launch1\\tem_forecast\\data\\Graps-3km\\'

    file = open(localpath + filename, 'wb')
    ftp.retrbinary('RETR' + remotepath + filename, file.write)
    print(file.read())
    file.close()
    ftp.quit()
if __name__ == "__main__":

    downloadfile(time='20200521', filename='20052108.000')

以下是输出以及报错信息
D:\program\anaconda\python.exe D:/launch1/tem_forecast/down_data.py

get ‘220 (vsFTPd 3.0.2)\n’
resp ‘220 (vsFTPd 3.0.2)’
cmd ‘USER MicapsData’
put ‘USER MicapsData\r\n’
get ‘331 Please specify the password.\n’
resp ‘331 Please specify the password.’
cmd ‘PASS ***************’
put ‘PASS ***************\r\n’
get ‘230 Login successful.\n’
resp ‘230 Login successful.’
welcome ‘220 (vsFTPd 3.0.2)’
220 (vsFTPd 3.0.2)
cmd ‘TYPE I’
put ‘TYPE I\r\n’
get ‘200 Switching to Binary mode.\n’
resp ‘200 Switching to Binary mode.’
cmd ‘PASV’
put ‘PASV\r\n’
get ‘227 Entering Passive Mode (xx,xxx,xx,xxx,xxx,xxx).\n’
resp ‘227 Entering Passive Mode (xx,xxx,xx,xxx,xxx,xxx).’
cmd ‘RETR20200521\GRAPES_3KM\TMP\2M_ABOVE_GROUND\20052108.000’
put ‘RETR20200521\GRAPES_3KM\TMP\2M_ABOVE_GROUND\20052108.000\r\n’
get ‘500 Unknown command.\n’
Traceback (most recent call last):
resp ‘500 Unknown command.’
File “D:/launch1/tem_forecast/down_data.py”, line 58, in
downloadfile(time=‘20200521’, filename=‘20052108.000’)
File “D:/launch1/tem_forecast/down_data.py”, line 26, in downloadfile
ftp.retrbinary(‘RETR’ + remotepath + filename, file.write)
File “D:\program\anaconda\lib\ftplib.py”, line 442, in retrbinary
with self.transfercmd(cmd, rest) as conn:
File “D:\program\anaconda\lib\ftplib.py”, line 399, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File “D:\program\anaconda\lib\ftplib.py”, line 365, in ntransfercmd
resp = self.sendcmd(cmd)
File “D:\program\anaconda\lib\ftplib.py”, line 273, in sendcmd
return self.getresp()
File “D:\program\anaconda\lib\ftplib.py”, line 246, in getresp
raise error_perm(resp)
ftplib.error_perm: 500 Unknown command.

Process finished with exit code 1

我不知道500 Unknown command.是因为什么报错,查了很久,都找不到,各位藏龙卧虎,还请指点。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值