How do I extract a tar file in Python?


Python tip:

You can extract a tar archive to a destination folder using tarfile.

An example👇

import tarfile

with tarfile.open("example.tar.gz") as tar:
    tar.extractall("destination_folder")