Unzip with Python

This code is what you need to unzip a zipped file with python. You need to install zipfile in the command line (windows butto + R and then write cmd):

pip install zipfile

in case you use more version of python, try this

py -3.9 -m pip install zipfile

to use it, for example in python 3.9 or any other version, substituting 3.9 with the version of python you want to install zipfile to.

So you see an example here. The example has a pymemo.zip file to unzip that is in the same dir of the file with this code here below. Otherwise, put the path for the zipped file. It will extract the files in the same directory, as I used “.”

So, that’s all. This is the code.

import zipfile
with zipfile.ZipFile("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.