Python 下载图片函数

来源:互联网 发布:大数据架构师是干嘛的 编辑:程序博客网 时间:2024/05/18 02:33
# -*- coding: utf-8 -*- import urllibdef DownImg(url, dirPath, name):  fr = urllib.urlopen(url)  stream = fr.read()  fr.close()  fw = open(dirPath+name,'wb')  # 图片是二进制 使用wbfw.write(stream)fw.close()print(dirPath+name)downImg('图片网址连接',"F:\\保存路径\\","图片文件名.jpg")