I\'m using this script to connect to sample ftp server and list available directories:
from ftplib import FTP ftp = FTP(\'ftp.cwi.nl\') # connect to host, defa
from ftplib import FTP ftp = FTP() ftp.connect(hostname, 21) ftp.login(username,password) try: ftp.cwd('your folder name') #do the code for successfull cd except Exception: #do the code for folder not exists