May 2018
Beginner to intermediate
452 pages
11h 26m
English
Downloading files from an FTP server involves either one of the retrbinary() or retrlines() methods, depending on whether we wish to use binary or text mode (as mentioned before, you should probably always use binary). Like storbinary, each method takes a command string as its first argument, but in this case it should be a valid RETR command (usually "RETR filename" will suffice).
The second argument is a callback function which will be called on every line (for retrlines()) or chunk (for retrbinary()). This callback can be used to store the downloaded data.
For example, take a look at the following code:
from ftplib import FTP from os.path import join filename = 'raytux.jpg' path = '/pub/ibiblio/logos/penguins' destination ...