当前位置: 移动技术网 > IT编程>脚本编程>Python > python urllib urlretrieve学习使用

python urllib urlretrieve学习使用

2019年04月19日  | 移动技术网IT编程  | 我要评论

优抚对象抚恤补助标准,性i交动态图,seqingyijipian

import urllib
import os

def reporthook(blocks_read, block_size, total_size):
    if not blocks_read:
        print "connection opened"
        return
    if total_size 


输出如下:

connection opened
read 1 blocks,  8192/55662, 15%
read 2 blocks,  16384/55662, 29%
read 3 blocks,  24576/55662, 44%
read 4 blocks,  32768/55662, 59%
read 5 blocks,  40960/55662, 74%
read 6 blocks,  49152/55662, 88%
read 7 blocks,  57344/55662, 103%

file: /tmp/tmp4lhkga
headers:
date: wed, 19 feb 2014 08:55:20 gmt
content-type: text/html; charset=utf-8
cache-control: max-age=1800
x-cacheable: mi-www-cacheable
server: mife/3.0
expires: wed, 19 feb 2014 09:25:20 gmt
powered-by-chinacache: miss from 010519h3sp.4
age: 990
content-length: 55662
powered-by-chinacache: hit from 01005143sg
connection: close

file exists before cleanup: true
file still exists: false

可以看到最后竟然读取了103%, 这是由于每次读取都是按照block 8192bytes来读取的,就算最后不满8192bytes, 也返回一个block的size

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网