您好,有問題請教您。o(∩_∩)o @清波
請問這個代碼中間加黑打下劃線的部分,里面為什么要有 ?“*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
2016-06-18
您好,可以更直觀的給出您的問題嗎?