Skip to content

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)
Code language: Python (python)

See also  Read the top n lines of a file in Python
Tags:
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x