tarfile模块

import tarfile
with tarfile.open('dir1.tar') as t: 
    for i in t.getmembers(): 
        print(i.name) 

tarfile中常用的函数:

1、getnames:获取tar包中的文件列表

2、extract: 提取单个文件

3、extractall : 提取所有文件

原文地址:https://www.cnblogs.com/superniao/p/10547655.html