Say we want to download the file.csv from the server we would simply write: > with ftplib.FTP('', 'user', 'password') as ftp: The retrbinary method retrieves a files in binary transfer mode: this is what you want to use to simply download a file from the server to your local machine and don’t need to interact with its content. To retrieve files from the server, we can use the retrbinary or retlines methods. Notice that the server is not guaranteed to respect the list of information we request. The output of the code above is the following. Let’s see an example: > with ftplib.FTP('', 'user', 'password') as ftp: The method returns a generator which yields a two-elements tuple for each file: the first element of each tuple is the file name the second a dictionary containing the requested information and their values.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |