📜  读取 tar.gz 文件 python 代码示例

📅  最后修改于: 2022-03-11 14:45:37.140000             🧑  作者: Mango

代码示例1
The docs tell us that None is returned by extractfile() if the member is a not a regular file or link.

One possible solution is to skip over the None results:

tar = tarfile.open("filename.tar.gz", "r:gz")
for member in tar.getmembers():
     f = tar.extractfile(member)
     if f is not None:
         content = f.read()