python 3的多成员gzip支持
multigzip的Python项目详细描述
多gzip
这个包是python2 gzip实现的一个端口,目标是 提供多成员gzip支持。当前python3的gzip实现 支持将多成员gzip文件作为单个流读取,但不支持 提供一次读取或写入一个成员的能力。这很有用 用于遍历gzip文件的成员,例如warc文件。
用法示例
frommultigzipimportGzipFilewithGzipFile(filename='tests.txt.gz',mode='wb')asf:f.write_member(b'Hello world 1')f.write_member(b'Hello world 2')f.write_member(b'Hello world 3')withGzipFile(filename='tests.txt.gz',mode='r')asf:# Note that read() returns a file-like object# this is unchanged vs the `gzip2` module ported# from warcprint(f.read_member().read())print(f.read_member().read())print(f.read_member().read())