请问大神,这个代码中间加黑打下划线的部分,里面为什么要有 “*100”呢?运行结果已经显示在问题最后,谢谢您!
#coding:utf-8
import urllib
def print_list(list):
for i in list:
print i
def progress(block,block_size,total_size):
print '%-7d/%-7d - %.2f%%'%(block*block_size,total_size,float(block*block_size)*100/total_size)
def retrieve():
fname,msg = urllib.urlretrieve('http://www.people.com.cn','index.html',reporthook = progress)
#因为retrieve的返回值是一个文件名和httpmessage的对象
print fname
if __name__ == '__main__':
retrieve()
运行结果:
0 /214710 - 0.00%
8192 /214710 - 3.82%
16384 /214710 - 7.63%
24576 /214710 - 11.45%
32768 /214710 - 15.26%
40960 /214710 - 19.08%
49152 /214710 - 22.89%
57344 /214710 - 26.71%
65536 /214710 - 30.52%
73728 /214710 - 34.34%
81920 /214710 - 38.15%
90112 /214710 - 41.97%
98304 /214710 - 45.78%
106496 /214710 - 49.60%
114688 /214710 - 53.42%
122880 /214710 - 57.23%
131072 /214710 - 61.05%
139264 /214710 - 64.86%
147456 /214710 - 68.68%
155648 /214710 - 72.49%
163840 /214710 - 76.31%
172032 /214710 - 80.12%
180224 /214710 - 83.94%
188416 /214710 - 87.75%
196608 /214710 - 91.57%
204800 /214710 - 95.38%
212992 /214710 - 99.20%
221184 /214710 - 103.02%
index.html
清波
相关分类