Python 返回二进制中的FTPlib错误
我在第行“ftp.retrbinary(“RETR”+文件名,localfile.write)”中遇到错误。它没有说我到底出了什么问题,只是得到了ftplib.error\u perm:500未知命令。索蒙能帮我解决这个问题吗Python 返回二进制中的FTPlib错误,python,python-3.x,ftplib,Python,Python 3.x,Ftplib,我在第行“ftp.retrbinary(“RETR”+文件名,localfile.write)”中遇到错误。它没有说我到底出了什么问题,只是得到了ftplib.error\u perm:500未知命令。索蒙能帮我解决这个问题吗 from ftplib import FTP def grabfile (): if not os.path.exists(dtt): os.makedirs(dtt) ftp = FTP('IP') ftp.login(u
from ftplib import FTP
def grabfile ():
if not os.path.exists(dtt):
os.makedirs(dtt)
ftp = FTP('IP')
ftp.login(user="ftpread", passwd = 'PSW')
ftp.cwd("/var/log/")
filename = "scxmlsoap.log"
#localfilename = "scxmlsoap.log"
localfile = open(filename, "wb")
ftp.retrbinary("RETR" + filename, localfile.write)
ftp.quit()
localfile.close()
f.close()
def main():
grabfile()
main()
只需在RETR后添加一个空格,这是一个更新版本
ftp = FTP('IP')
ftp.login(user="ftpread", passwd = 'PSW')
ftp.cwd("/var/log/")
filename = "scxmlsoap.log"
#localfilename = "scxmlsoap.log"
localfile = open(filename, "wb")
ftp.retrbinary("RETR %s" % filename, localfile.write) # <-- a space added
ftp.quit()
localfile.close()
f.close()
ftp=ftp('IP'))
ftp.login(user=“ftpread”,passwd='PSW')
ftp.cwd(“/var/log/”)
filename=“scxmlsoap.log”
#localfilename=“scxmlsoap.log”
localfile=open(文件名为“wb”)
ftp.retrbinary(“RETR%s”%filename,localfile.write)#在'RETR'
和文件名之间没有空格这一事实意味着您要发送一个命令:'RETRscxmlsoap.log'
。当然,这不会被解释为您需要的'RERT'
命令
只需在它们之间添加一个空格:'RERT{}.format(filename)
它显示error\u perm。可能是权限错误,这意味着您没有写入尝试写入的文件的权限?