用Python下载一只猫
访问网站:
http://placekitten.com/g/200/300
就可以得到一只猫的照片
你可以使用右键图片另存为将其保存到本地
现在用Python来实现
import urllib.request
response = urllib.request.urlopen("http://placekitten.com/g/200/300")
cat_img = response.read()
with open('cat_200_300.jpg', 'wb') as f:
f.write(cat_img)
运行,在代码所在的文件夹出现了cat_200_300.jpg