how to unzip files using zipfile module python
import zipfile
with zipfile.ZipFile("file.zip","r") as zip_ref:
zip_ref.extractall("targetdir")
how to unzip files using zipfile module python
import zipfile
with zipfile.ZipFile("file.zip","r") as zip_ref:
zip_ref.extractall("targetdir")
make zipfile from directory py
import zipfile
filePaths = [] # Make an array string with all paths to files
for root, directories, files in os.walk("MyDirectoryPath"): # Scans for all subfolders and files in MyDirectoryPath
for filename in files: # loops for every file
filePath = os.path.join(root, filename) # Joins both the directory and the file name
filePaths.append(filePath) # appends to the array
z = zipfile.ZipFile("MyDirectoryPathWithZipExt.zip", 'w')
with z:
for file in filePaths: # Loops for all files in array
z.write(file) # Writes file to MyDirectoryPathWithZipExt.zip
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us