How to Create Zip Archive of Directory in Python


If you need to create a zip of a directory using Python, then you can do the following:

Create a Zip using shutil in Python

import os
import shutil

filename = "compressed_archive"
format = "zip"
directory = os.getcwd()

shutil.make_archive(filename, format, directory)