gzip

gzip.GzipFile([filename[, mode[, compresslevel[, fileobj[, mtime]]]]])

必须给出filename或fileobj

gzip.open(filename[, mode[, compresslevel]])

例子

import gzip
with gzip.open('file.txt.gz', 'rb') as f:
    file_content = f.read()

import gzip
content = "Lots of content here"
with gzip.open('file.txt.gz', 'wb') as f:
    f.write(content)

你可能感兴趣的:(gzip)