Thursday, September 4, 2025
HomeLanguagesPython | shutil.get_archive_formats() method

Python | shutil.get_archive_formats() method

Shutil module in Python provides many functions of high-level operations on files and collections of files. It comes under Python’s standard utility modules. This module helps in automating process of copying and removal of files and directories.

shutil.get_archive_formats() method in Python is used to get the list of supported formats for archiving.
Following formats are available by default for archiving:

  • zip: ZIP file
  • tar: uncompressed tar file.
  • gztar: gzip’ed tar-file
  • bztar: bzip2’ed tar-file
  • xztar: xz’ed tar-file

Syntax: shutil.get_archive_formats()

Parameter: No parameter is required

Return Type: This method returns a list which represents the formats supported for archiving. Each element of the list is a tuple (name, description).

Code: Use of shutil.get_archive_formats() method




# Python program to explain shutil.get_archive_formats() method 
    
# importing shutil module 
import shutil
  
# Get the list of
# supported archiving formats
formats = shutil.get_archive_formats()
  
  
# Print the list of
# supported archiving formats 
print("Supported archiving formats:\n", formats)


Output:

Supported archiving formats:
[('bztar', "bzip2'ed tar-file"), ('gztar', "gzip'ed tar-file"),
('tar', 'uncompressed tar file'), ('xztar', "xz'ed tar-file"), ('zip', 'ZIP file')]

Reference: https://docs.python.org/3/library/shutil.html

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32264 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6632 POSTS0 COMMENTS
Nicole Veronica
11800 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11860 POSTS0 COMMENTS
Shaida Kate Naidoo
6749 POSTS0 COMMENTS
Ted Musemwa
7025 POSTS0 COMMENTS
Thapelo Manthata
6698 POSTS0 COMMENTS
Umr Jansen
6718 POSTS0 COMMENTS