Python Glossary Русский

all Python 3shutilfunction

shutil.get_archive_formats()

archives

Returns the list of formats make_archive() can create — (name, description) pairs.

Syntax

shutil.get_archive_formats() -> list[tuple[str, str]]

The list depends on the Python build: bztar, xztar and zstdtar (3.14+) appear only if the interpreter was built with bz2, lzma and compression.zstd — so check it before calling make_archive with an unusual format. Only creation formats are listed here: unpackable ones and their extensions come from the separate get_unpack_formats(), and the two sets need not match.

Examples

import shutil
names = [name for name, desc in shutil.get_archive_formats()]
print(names)  # → ? ['bztar', 'gztar', 'tar', 'xztar', 'zip', 'zstdtar'] — зависит от сборки
print('zip' in names, 'tar' in names)  # → True True

See also

Open in the full glossarydocs.python.orgReport an inaccuracy