network.py 文件源码

python
阅读 46 收藏 0 点赞 0 评论 0

项目:twentybn-dl 作者: TwentyBN 项目源码 文件源码
def total_blocks_and_bytes(self):
        total_blocks, total_bytes = 0, 0
        for u in self.input_urls:
            head_response_headers = requests.head(u).headers
            if 'Content-Length' not in head_response_headers:
                m = "The url: '{}' doesn't support the 'Content-Length' field.".format(u)
                raise ContentLengthNotSupportedException(m)
            else:
                remote_size = int(head_response_headers['Content-Length'])
            total_bytes += remote_size
            num_blocks, last_block_size = divmod(remote_size, self.blocksize)
            total_blocks += num_blocks
            if last_block_size:
                total_blocks += 1
        return total_blocks, total_bytes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号