Created
June 21, 2018 06:12
-
-
Save ColtonPhillips/3f2a0ed4a716957e25274cca03c735ac to your computer and use it in GitHub Desktop.
a good file
This file contains hidden or 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
# Example | |
from urllib2 import urlopen | |
import random | |
cat = (random.randint(100,500), random.randint(100,500)) | |
site = urlopen('http://placekitten.com/{}/{}'.format(*cat)) | |
data = site.read() | |
cat_file = open('demoncat.jpg','w') | |
cat_file.write(data) | |
cat_file.close() | |
with open('cat.jpg','wb') as f: | |
f.write(data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment