假日咖啡的博客

HolidayCoffee's Blog

python批量下载图片

import urllib
import os
 
def download(url,savepath):
	local = url.split('/')[-1]
	local = savepath+"\\"+local 
	return urllib.urlretrieve(url,local)
 
	
path = "C:\Users\Administrator\Desktop\downloadlist\images"
 
f = open("list.txt")
txt = f.read()
list = txt.split("\n")
 
for n in list:
	if(n!=""):
		print download(n,path)
 
 
 
f.close()