尝试解压缩 tar.gz 文件并将其保存为文件夹中的多个可读文本文件,然后重新压缩

Trying to unzip tar.gz file and save it as multiple readable text files in a folder and then recompress it

import gzip
import os
os.mkdir('uncompressed')
with gzip.open("Raw_feature_count_data.tar.gz", "rt") as f:
    output=f.read()
output

尝试使用 python 解压缩多个特征计数文本文件,代码确实解压缩了它,但它不可读并将所有文件合并在一起。如有任何建议,我们将不胜感激。

Tarfile is the module to use. And it can handle gzip compression using the r:gz mode. From the examples at the bottom of documentation

import tarfile
tar = tarfile.open("sample.tar.gz")
tar.extractall()
tar.close()