Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download file from ftp?

I'm scripting an install script in python.

How do I download file from ftp in python?

Operating system -- Windows XP - if that makes a difference.

like image 511
Zygimantas Avatar asked Dec 28 '22 15:12

Zygimantas


1 Answers

from urllib2 import urlopen
req = urlopen('ftp://ftp.gnu.org/README')

Then you can use req.read() to load the file content into a variable or do anything else with it, or shutil.copyfileobj to save the content to a disk without loading it to memory.

like image 115
wRAR Avatar answered Jan 04 '23 15:01

wRAR