以下是導致錯誤的相關代碼。在python中使用ftplib時
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
我從來沒有見過這個錯誤,以及有關爲什麼我可能會得到它的任何信息將是有益的和讚賞。
完整的錯誤消息: [錯誤10060]連接嘗試失敗,因爲連接的方沒有正確一段時間後響應或已建立的連接失敗,因爲連接的主機沒有反應
應當注意當我手動(即打開dos提示符並使用ftp命令推送文件)從腳本所在的同一臺機器上推送文件時,我沒有任何問題。
10060看起來像是超時錯誤。 – eumiro 2011-02-09 15:36:43