python的urllib模块显示下载进度示例

977次阅读  |  发布于5年以前

复制代码 代码如下:

def report_hook(count, block_size, total_size):
... print '%02d%%'%(100.0 count block_size/ total_size)
...
urllib.urlretrieve("http://sports.sina.com.cn/", reporthook= report_hook)
00%
01%
03%
...

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8