最佳答案
                                        
                                                                        
                                我试图使用python的requests模块从web下载并保存一张图像。
下面是我使用的(工作)代码:
img = urllib2.urlopen(settings.STATICMAP_URL.format(**data))
with open(path, 'w') as f:
f.write(img.read())
下面是使用requests的新(无效)代码:
r = requests.get(settings.STATICMAP_URL.format(**data))
if r.status_code == 200:
img = r.raw.read()
with open(path, 'w') as f:
f.write(img)
你能帮助我从响应中使用requests的哪个属性吗?