Python3下载文件或图片方法
1、使用requests
importos
importrequests
defdownload_file(url,store_path):
filename=url.split("/")[-1]
filepath=os.path.join(store_path,filename)
file_data=requests.get(url,allow_redirects=True).content
withopen(filepath,'wb')ashandler:
handler.write(file_data)
2、使用urllib.request.urlretrieve
importos
fromurllib.requestimporturlretrieve
defdownload_file(url,store_path):
filename=url.split("/")[-1]
filepath=os.path.join(store_path,filename)
urlretrieve(url,filepath)热门推荐
10 新房上梁简短祝福语大全
11 上班祝福语简短10字
12 升学宴同学祝福语简短
13 蛋糕祝福语简短闺蜜
14 学生国庆简短的祝福语
15 餐饮生日祝福语简短独特
16 新年祝福语大全简短感谢
17 开业祝福语大全简短赞美
18 新年祝福语简短又好听