我正在使用python中的一个项目,我只需要提取tar存档的子文件夹而不是所有文件.我试着用
tar = tarfile.open(tarfile) tar.extract("dirname", targetdir)
但这不起作用,它不提取给定的子目录也没有抛出异常.我是python的初学者.另外如果上面的函数对目录不起作用,那么这个命令和tar.extractfile()之间的区别是什么?
python tar
python ×1
tar ×1