标签:
来源:http://www.jb51.net/article/42630.htm
urllib模块 urlretrieve方法
import urllib def callbackfunc(blocknum, blocksize, totalsize): ‘‘‘回调函数 @blocknum: 已经下载的数据块 @blocksize: 数据块的大小 @totalsize: 远程文件的大小 ‘‘‘ percent = 100.0 * blocknum * blocksize / totalsize if percent > 100: percent = 100 print "%.2f%%"% percent url = ‘http://www.sina.com.cn‘ local = ‘d:\\sina.html‘ urllib.urlretrieve(url, local, callbackfunc)
标签:
原文地址:http://www.cnblogs.com/dplearning/p/5860278.html