How to use FTP in Python?

PythonServer Side ProgrammingProgramming

You can use the ftplib module in Python. It allows you to write programs that perform a variety of automated FTP jobs. You can easily connect to a FTP server to retrieve files and process them locally.

example

import ftplib
ftp = ftplib.FTP('ftp.yourserver.com', 'yourusername', 'your@email.address')
print "File List: "
files = ftp.dir()
print(files)
ftp.cwd("/tmp") #change working directory to /tmp

Above code connects to a FTP server and prints the file list in the home directory of that server.

raja
Published on 28-Dec-2017 07:05:45
Advertisements