Unzip compressed files with Python and zipfile

If you need to unzip a compressed files using python there is a module to do that easily. This can be useful in many ways. I use it, for example, to clone some scripts into a new folder passing the path where the zipped files with the code is and unzipping it in the new folder where I need that code. This makes everything really fast and simple to do it. I also put this code into a folder that python looks for automatically, placing it in a folder wich path is in a .pth file in the site-packages directory of the installation of python (see the post for this).

To unzip a file there is this module, zipfile, that make you do it:

import zipfile
with zipfile.ZipFile("G:/pymemo/pymemo.zip", 'r') as zip_ref:
zip_ref.extractall(".")


Subscribe to the newsletter for updates
Tkinter templates
Avatar My youtube channel

Twitter: @pythonprogrammi - python_pygame

Videos

Speech recognition game

Pygame's Platform Game

Other Pygame's posts

Published by pythonprogramming

Started with basic on the spectrum, loved javascript in the 90ies and python in the 2000, now I am back with python, still making some javascript stuff when needed.