Fix Python – How to download image using requests

I’m trying to download and save an image from the web using python’s requests module.
Here is the (working) code I used:
img = urllib2.urlopen(settings.STATICMAP_URL.format(**data))
with open(path, ‘w’) as f:
f.write(img.read())

Here is the new (non-working) code using requests:
r = requests.get(settings.STATICMAP_URL.format(**data))
if r.sta….