FTP サーバーから .zip ファイルをダウンロードしようとしていますが、次のエラーが発生し続けます。
File "C:/filename.py", line 37, in handleDownload
file.write(block)
TypeError: descriptor 'write' requires a 'file' object but received a 'str'
これが私のコードです(http://postneo.com/stories/2003/01/01/beyondTheBasicPythonFtplibExample.htmlから借用):
def handleDownload(block):
file.write(block)
print ".",
ftp = FTP('ftp.godaddy.com') # connect to host
ftp.login("auctions") # login to the auctions directory
print ftp.retrlines("LIST")
filename = 'auction_end_tomorrow.xml.zip'
file = open(filename, 'wb')
ftp.retrbinary('RETR ' + filename, handleDownload)
file.close()
ftp.close()