Monday, April 21, 2025

How to Unzip a File - Python

import zipfile

target = 'OLD-BACKUP.zip'

handle = zipfile.ZipFile(target)

handle.extractall('c:\\Python38-64\\UNPACKED')

handle.close()

This Python code uses the zipfile module to extract all files from a ZIP archive called 'OLD-BACKUP.zip' to a target directory 'c:\Python38-64\UNPACKED'.

The zipfile.ZipFile method is used to create a handle to the specified ZIP file. The extractall method is then called on the handle to extract all files in the ZIP archive to the target directory. Finally, the handle.close() method is called to close the handle to the ZIP file.

Note that if any of the files being extracted already exist in the target directory, they will be overwritten.

No comments:

Post a Comment

Tkinter Introduction - Top Widget, Method, Button

First, let's make shure that our tkinter module is working ok with simple  for loop that will spawn 5 instances of blank Tk window .  ...