Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Retrieving files

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content