import urllib
def download(imagelist,local):
x=1
for i in imagelist:
socket.setdefaulttimeout(1000)
urllib.request.urlretrieve(i,local+'%s.jpg'%x,schedule)
x+=1
print("*********")
def schedule(a,b,c):
'''''
a:已经下载的数据块
b:数据块的大小
c:远程文件的大小
'''
per = 100.0 * a * b / c
if per > 100 :
per = 100
print('%.2f%%' % per)
urllib.request.urlretrieve()第三个参数为回调函数