您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

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

在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存储实际的未压缩大小。但是,我认为 它没有公开公开,因此您可能必须破解它才能公开。不太确定,对不起。

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

python 2022/1/1 18:50:30 有370人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶