python根据url下载图片的方法
python根据url下载图片的方法
·
1、使用urllib.request.urlretrieve()方法
from urllib import request
request.urlretrieve(url, path + '.jpg')#下载图片
2、使用二进制的方式写入图片
import requests
with open(path+name+'.jpg','wb') as f:
img = requests.get(url,headers = headers).content
#url是img的url
f.write(img)
更多推荐
所有评论(0)