python gz解压

def decompose_file(data):
    # ungz_file_path = gz_file_path.replace(".gz", "")
    # with gzip.open(gz_file_path, 'rb') as f_in:
    #     with open(ungz_file_path, 'wb') as f_out:
    #         shutil.copyfileobj(f_in, f_out)
    new_data = gzip.decompress(data)
    return new_data

其中data是源文件的buffer,new_data是解压之后的新文件的buffer,直接操作就行了。

posted @ 2023-02-16 11:20  公众号python学习开发  阅读(71)  评论(0编辑  收藏  举报