栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

在python中获取.gz文件的未压缩大小

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

在python中获取.gz文件的未压缩大小

该gzip格式指定一个名为领域

ISIZE
是:

它包含原始(未压缩)输入数据模2 ^ 32的大小。

在gzip.py中,我假设这是您用于gzip支持的内容,其中有一个称为define的方法

_read_eof
,如下所示:

def _read_eof(self):    # We've read to the end of the file, so we have to rewind in order    # to reread the 8 bytes containing the CRC and the file size.    # We check the that the computed CRC and size of the    # uncompressed data matches the stored values.  Note that the size    # stored is the true file size mod 2**32.    self.fileobj.seek(-8, 1)    crc32 = read32(self.fileobj)    isize = U32(read32(self.fileobj))   # may exceed 2GB    if U32(crc32) != U32(self.crc):        raise IOError, "CRC check failed"    elif isize != LOWU32(self.size):        raise IOError, "Incorrect length of data produced"

在那里,您可以看到

ISIZE
正在读取该字段,但这只是为了将其与
self.size
错误检测进行比较。然后,这应意味着
GzipFile.size
存储实际的未压缩大小。但是,我
认为 它没有公开公开,因此您可能必须破解它才能公开。不太确定,对不起。

我现在只是看了所有这些,而我还没有尝试过,所以我可能是错的。我希望这对您有用。对不起,如果我误解了你的问题。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/624917.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号