tarfile

The tarfile module is used to manipulate tar archive files. Using this module, it is possible to read and write tar files, with or without compression.


is_tarfile(name)

Returns True if name appears to be a valid tar file that can be read by this module.


open([name [, mode [, fileobj [, bufsize]]]])

Creates a new TarFile object with the pathname name. mode is a string that specifies how the tar file is to be opened. The mode string is a combination of a file mode and a compression scheme specified as 'filemode[:compression]'. Valid combinations include the following:

ModeDescription
'r'Open for reading. If the file is compressed, it is decompressed transparently. This is the default mode.
'r:'Open for reading without compression.
'r:gz' ...

Get Python: Essential Reference, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.