Как загрузить файл через FTP с помощью Python ftplib

У меня есть следующий код, который легко подключается к FTP-серверу и открывает zip-файл. Я хочу загрузить этот файл в локальную систему. Как это сделать?

# Open the file for writing in binary mode
print 'Opening local file ' + filename
file = open(filename, 'wb')

# Download the file a chunk at a time
# Each chunk is sent to handleDownload
# We append the chunk to the file and then print a '.' for progress
# RETR is an FTP command

print 'Getting ' + filename
ftp.retrbinary('RETR ' + filename, handleDownload)

# Clean up time
print 'Closing file ' + filename
file.close()
60
задан Lev Levitsky 20 July 2012 в 06:23
поделиться