I read through the zipfile documentation, but couldn't understand how to unzip a file, only how to zip a file. How do I unzip all the contents of a zip file into the same directory?
with zipfile.ZipFile(path_to_zip_file, 'r') as zip_ref:
That's pretty much it!
If you are using Python 3.2 or later:
with zipfile.ZipFile("file.zip","r") as zip_ref:
You dont need to use the close or try/catch with this as it uses the
context manager construction.