Answers for "python zip"

7

python zip folder

import shutil
shutil.make_archive(output_filename, 'zip', dir_name)
Posted by: Guest on May-14-2020
1

python zip folder

import os
import zipfile

def zip_directory(folder_path, zip_path):
    with zipfile.ZipFile(zip_path, mode='w') as zipf:
        len_dir_path = len(folder_path)
        for root, _, files in os.walk(folder_path):
            for file in files:
                file_path = os.path.join(root, file)
                zipf.write(file_path, file_path[len_dir_path:])
                
zip_directory('C:/FolderToZip', 'C:/Folder.zip')
Posted by: Guest on June-19-2020
1

python how to download zip

url = 'https://codeload.github.com/fogleman/Minecraft/zip/master'
 
# downloading with requests
 
# import the requests library
import requests
 
 
# download the file contents in binary format
r = requests.get(url)
 
# open method to open a file on your system and write the contents
with open("minemaster1.zip", "wb") as code:
    code.write(r.content)
 
 
# downloading with urllib
 
# import the urllib library
import urllib
 
# Copy a network object to a local file
urllib.urlretrieve(url, "minemaster.zip")
Posted by: Guest on June-05-2020
2

zippython

l1 = [1, 2, 3]
l2 = ['a', 'b', 'c']
list(zip(l1, l2))
#-> [(1, 'a'), (2, 'b'), (3, 'c')]
Posted by: Guest on May-27-2021
0

python zip files

import shutil
shutil.make_archive(output_filename, 'zip', dir_name)
Posted by: Guest on July-07-2021
1

zip python

>>> x = [1, 2, 3]
>>> y = [4, 5, 6]
>>> zipped = zip(x, y)
>>> list(zipped)
[(1, 4), (2, 5), (3, 6)]
>>> x2, y2 = zip(*zip(x, y))
>>> x == list(x2) and y == list(y2)
True
Posted by: Guest on April-30-2020

Python Answers by Framework

Browse Popular Code Answers by Language