tarfile — Read and write tar archive files — Python 3.16.0a0 documentation

docs.python.org

Tin mới

zipfile — Work with ZIP archives

Python Module Index

3.16.0a0 Documentation

The Python Standard Library

Data Compression and Archiving

gzip: Interfaces for gzip compression and decompression using file objects.

reads and writes gzip, bz2, compression.zstd, and lzma compressed archives if the respective modules are available.

bz2: Interfaces for bzip2 compression and decompression.

reads and writes gzip, bz2, compression.zstd, and lzma compressed archives if the respective modules are available.

compression.zstd: Low-level interface to compression and decompression routines in the zstd library.

reads and writes gzip, bz2, compression.zstd, and lzma compressed archives if the respective modules are available.

lzma: A Python wrapper for the liblzma compression library.

reads and writes gzip, bz2, compression.zstd, and lzma compressed archives if the respective modules are available.

Requirements for optional modules

reads and writes gzip, bz2, compression.zstd, and lzma compressed archives if the respective modules are available.

io.RawIOBase.write

Return a TarFile object for the pathname name. For detailed information on TarFile objects and the keyword arguments that are allowed, see TarFile Objects.

sys.getfilesystemencoding()

The default character encoding: 'utf-8' on Windows, the value returned by sys.getfilesystemencoding() otherwise.

Archiving operations

Documentation of the higher-level archiving facilities provided by the standard shutil module.

site configuration

The extraction filter used as a default for the filter argument of extract() and extractall().

copy: Shallow and deep copy operations.

A TarInfo object represents one member in a TarFile. Aside from storing all required attributes of a file (like file type, size, time, permissions, owner etc.), it provides some useful methods to determine its type. It d

os.stat_result.st_mtime

Time of last modification in seconds since the epoch, as in os.stat_result.st_mtime.

os.path.normpath()

Normalize filenames (TarInfo.name) that contain .. components using os.path.normpath(). Note that this removes internal .. components, which may change the meaning of the name if it traverses symbolic links.

new temporary directory

Extract to a new temporary directory to prevent e.g. exploiting pre-existing links, and to make it easier to clean up after a failed extraction.