tar -xf archive.tar.bz2Copy
Here is what the above code is Doing:
1. The tarfile module makes it easy to create and extract tar archives.
2. The first argument to tarfile.open() specifies that we want to create a tar archive.
3. The second argument is the name of the tar archive we want to create.
4. The third argument tells the tarfile module to use gzip compression.
5. The next line adds the file named foo.txt to the tar archive.
6. The final line closes the tar archive.