这是导致错误的相关代码。
ftp = ftplib.FTP('server')
ftp.login(r'user', r'pass')
#change directories to the "incoming" folder
ftp.cwd('incoming')
fileObj = open(fromDirectory + os.sep + f, 'rb')
#push the file
try:
msg = ftp.storbinary('STOR %s' % f, fileObj)
except Exception as inst:
msg = inst
finally:
fileObj.close()
if '226' not in msg:
#handle error case
我以前从未见过这个错误,任何关于我为什么会得到它的信息都会很有用和感激。
完成错误信息:[Errno 10060] A connection attempt failed because the connected 方在一段时间后没有正确响应,或者由于连接的主机没有响应而建立连接失败
应该注意的是,当我手动(即打开dos-prompt并使用ftp命令推送文件)从脚本所在的同一台机器推送文件时,我没有问题。