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 : 提取所有文件

posted @ 2019-03-17 16:50  superniao  阅读(155)  评论(0编辑  收藏  举报