1>>> ftps = FTP_TLS('ftp.pureftpd.org')
2>>> ftps.login()
3'230 Anonymous user logged in'
4>>> ftps.prot_p()
5'200 Data protection level set to "private"'
6>>> ftps.nlst()
7['6jack', 'OpenBSD', 'antilink', 'blogbench', 'bsdcam', 'clockspeed', 'djbdns-jedi', 'docs', 'eaccelerator-jedi', 'favicon.ico', 'francotone', 'fugu', 'ignore', 'libpuzzle', 'metalog', 'minidentd', 'misc', 'mysql-udf-global-user-variables', 'php-jenkins-hash', 'php-skein-hash', 'php-webdav', 'phpaudit', 'phpbench', 'pincaster', 'ping', 'posto', 'pub', 'public', 'public_keys', 'pure-ftpd', 'qscan', 'qtc', 'sharedance', 'skycache', 'sound', 'tmp', 'ucarp']
8
1>>> from ftplib import FTP
2>>> ftp = FTP('ftp.debian.org') # connect to host, default port
3>>> ftp.login() # user anonymous, passwd anonymous@
4'230 Login successful.'
5>>> ftp.cwd('debian') # change into "debian" directory
6>>> ftp.retrlines('LIST') # list directory contents
7-rw-rw-r-- 1 1176 1176 1063 Jun 15 10:18 README
8...
9drwxr-sr-x 5 1176 1176 4096 Dec 19 2000 pool
10drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project
11drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools
12'226 Directory send OK.'
13>>> with open('README', 'wb') as fp:
14>>> ftp.retrbinary('RETR README', fp.write)
15'226 Transfer complete.'
16>>> ftp.quit()
17