“Python Extract Zip File tanpa Struktur Direktori” Kode Jawaban

Direktori Ekstrak Zip Python

import zipfile

archive = zipfile.ZipFile('archive.zip')

for file in archive.namelist():
    if file.startswith('foo/'):
        archive.extract(file, 'destination_path')
Exuberant Earthworm

Python Extract Zip File tanpa Struktur Direktori

import os
import shutil
import zipfile

my_dir = r"D:\Download"
my_zip = r"D:\Download\my_file.zip"

with zipfile.ZipFile(my_zip) as zip_file:
    for member in zip_file.namelist():
        filename = os.path.basename(member)
        # skip directories
        if not filename:
            continue

        # copy file (taken from zipfile's extract)
        source = zip_file.open(member)
        target = open(os.path.join(my_dir, filename), "wb")
        with source, target:
            shutil.copyfileobj(source, target)
Exuberant Earthworm

cara mengekstrak file zip menggunakan python

ZipFile.extractall(path=None, members=None, pwd=None)
Xerothermic Xenomorph

Jawaban yang mirip dengan “Python Extract Zip File tanpa Struktur Direktori”

Pertanyaan yang mirip dengan “Python Extract Zip File tanpa Struktur Direktori”

Lebih banyak jawaban terkait untuk “Python Extract Zip File tanpa Struktur Direktori” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya