Created
May 27, 2012 11:53
-
-
Save mikezhuyuan/2810241 to your computer and use it in GitHub Desktop.
python download file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
BUFFER_SIZE = 256*1024 | |
url = 'http://downloads.sourceforge.net/project/pydev/pydev/PyDev%202.5.0/PyDev%202.5.0.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fpydev%2Ffiles%2F&ts=1338118912&use_mirror=nchc' | |
res = urllib2.urlopen(url) | |
with open('PyDev.zip', 'wb') as f: | |
while True: | |
chunk = res.read(BUFFER_SIZE) | |
if(not chunk): | |
break | |
f.write(chunk) | |
print len(chunk) |
how?
download file.py
Download
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry, but can someone explain how this code works?