0
15941
"sample.tar.gz" file contains 2 files 'test.txt', 'sample.html'
Print files withn the tar file
import tarfile
filename = "sample.tar.gz"
tf = tarfile.open(filename)
print(tf.getnames())
['test.txt', 'sample.html']
Extract all the files within tar.gz file
import tarfile
filename = "sample.tar.gz"
tf = tarfile.open(filename)
tf.extractall('D:/tmp') # 'D:/tmp' is path
The files will be etracted to "D:/tmp"
Comment here