Python ftplib 未登录到 FileZilla 服务器

Python ftplib not logging in to FileZilla server

我正在尝试将 Python 中的文件上传到位于 ftp.scratso.com 的 FileZilla FTP 服务器,但我不断收到此错误:

Traceback (most recent call last):
File "PythianRealms.py", line 2332, in <module>
  ftp = ftplib.FTP("ftp.scratso.com", "PythianRealms", "password")
File "C:\Python32\lib\ftplib.py", line 115, in __init__
  self.login(user, passwd, acct)
File "C:\Python32\lib\ftplib.py", line 400, in login
  resp = self.sendcmd('USER ' + user)
File "C:\Python32\lib\ftplib.py", line 255, in sendcmd
  return self.getresp()
File "C:\Python32\lib\ftplib.py", line 230, in getresp
  raise error_proto(resp)
ftplib.error_proto:  written by Tim Kosse (Tim.Kosse@gmx.de)

我已经尝试寻找解决方案,但我还没有发现这个问题出现在其他地方。

密码是这样的(密码已更改):

ftp = ftplib.FTP("ftp.scratso.com", "PythianRealms", "password")
mapsock = urllib.request.urlopen("http://92.234.196.233/launcher-version.txt")
mapnum = str(mapsock.read()).split("'")[1]
mapsock.close()
f = open("tempmap.txt", "rb")
ftp.storbinary("STOR "+mapnum+".prm", f)
f.close()
ftp.quit()

如有任何帮助,我们将不胜感激。

谢谢。

编辑: 在服务器日志中显示:

(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> 220 FileZilla Server version 0.9.41 beta written by Tim Kosse (Tim.Kosse@gmx.de) Please visit http://sourceforg
(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> USER PythianRealms
(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> 331 Password required for pythianrealms

服务器发回以下欢迎信息:

220 FileZilla Server version 0.9.41 beta\r
written by Tim Kosse (Tim.Kosse@gmx.de)\r
Please visit http://sourceforg\r\n

这是一条非常奇怪的欢迎信息,因为它有点多行,但不是真正的多行。这些行仅由 \r 而不是 \r\n 分隔,并且它不遵循用于 FTP 多行响应的标准,即第一行应为“220-...”和最后一行“220 ...”。

虽然我看不到 RFC 959 中单行响应中允许的字符的明确定义,但文本通常被定义为不包括控制字符,如 \r 除了行尾。因此,难怪 ftplib 无法正确处理这种奇怪的响应。