“Folder Zip Python” Kode Jawaban

Folder Zip Python

import shutil
shutil.make_archive(output_filename, 'zip', dir_name)
DigitalBorder

Folder Zip Python

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')
Gentle Gazelle

Folder Zip Python

#!/usr/bin/env python
import os
import zipfile

def zipdir(path, ziph):
    # ziph is zipfile handle
    for root, dirs, files in os.walk(path):
        for file in files:
            ziph.write(os.path.join(root, file))

if __name__ == '__main__':
    zipf = zipfile.ZipFile('Python.zip', 'w', zipfile.ZIP_DEFLATED)
    zipdir('tmp/', zipf)
    zipf.close()
DigitalBorder

Jawaban yang mirip dengan “Folder Zip Python”

Pertanyaan yang mirip dengan “Folder Zip Python”

Lebih banyak jawaban terkait untuk “Folder Zip Python” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya