shutil.make_archive()
shutil.make_archive() is a Python function in the Shutil Module category. Creates an archive file (zip, tar, gztar, bztar, xztar) from a directory. The syntax is shutil.make_archive(base_name, format, root_dir=None, base_dir=None, verbose=False, dry_run=False, owner=None, group=None, logger=None). Parameters: base_name, format, root_dir. Returns: Archive path string. A typical example: shutil.make_archive("backup", "zip", "project/")
# Creates backup.zip containing project/. A close sibling is shutil.copy(), which copies a file from src to dst (or into a directory). A close sibling is shutil.copy2(), which like copy() but also preserves metadata (timestamps, permissions). A close sibling is shutil.copytree(), which recursively copies an entire directory tree. A close sibling is shutil.move(), which moves a file or directory to a new location. More about this category: High-level file operations — copy, move, copytree, rmtree, make_archive. For a broader walkthrough, read the Shutil Module guide. Related Shutil Module entries: shutil.copy(), shutil.copy2(), shutil.copytree(), shutil.move(), shutil.rmtree(), shutil.get_archive_formats().