Created
November 8, 2010 22:56
-
-
Save dpritchett/668429 to your computer and use it in GitHub Desktop.
Download a file using python
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
""" | |
See the python docs for more on file writes: | |
http://docs.python.org/tutorial/inputoutput.html#reading-and-writing-files | |
""" | |
import urllib | |
img = urllib.urlopen(r'http://www.google.com/logos/2010/xraydiscovery2010-res.gif') | |
f = open ('/pythonwrite.gif', 'wb') # wb = binary write mode | |
for line in img.readlines(): | |
f.write(line) | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Whipped up in answer to a question on StackOverflow chat.