About 214,000 results
Open links in new tab
  1. zipfile — Work with ZIP archives — Python 3.13.3 documentation

    compression is the ZIP compression method to use when writing the archive, and should be ZIP_STORED, ZIP_DEFLATED, ZIP_BZIP2 or ZIP_LZMA; unrecognized values will cause NotImplementedError to be raised.

  2. Creating a zip file with compression in python using the zipfile …

    To enable compression, specify compression method in the constructor: zip = zipfile.ZipFile(loczip, "w", zipfile.ZIP_DEFLATED) I think you are asking to remove the relative paths of files inside the zip file. If you really want that, you could write: zip.write(locfile, os.path.basename(locfile))

  3. zip - Python zipfile, How to set the compression level? - Stack Overflow

    Dec 17, 2014 · Python supports zipping files when zlib is available, ZIP_DEFLATE. see: https://docs.python.org/3.4/library/zipfile.html. The zip command-line program on Linux supports -1 fastest, -9 best. Is there a way to set the compression level of a …

  4. Data Compression and Archiving — Python 3.13.3 documentation

    4 days ago · The modules described in this chapter support data compression with the zlib, gzip, bzip2 and lzma algorithms, and the creation of ZIP- and tar-format archives. See also Archiving operations provided by the shutil module.

  5. Zip and unzip files with zipfile and shutil in Python

    Aug 13, 2023 · In Python, the zipfile module allows you to zip and unzip files, i.e., compress files into a ZIP file and extract a ZIP file. You can also easily zip a directory (folder) and unzip a ZIP file using the make_archive() and unpack_archive() functions from the shutil module. See the following article on the built-in zip() function.

  6. Working with zip files in Python - GeeksforGeeks

    Jul 22, 2021 · This article explains how one can perform various operations on a zip file using a simple python program. What is a zip file? ZIP is an archive file format that supports lossless data compression.

  7. Is there any method to compress ZIP files in python?

    Aug 31, 2021 · When using ZIP_DEFLATED integers 0 through 9 are accepted (see zlib for more information). When using ZIP_BZIP2 integers 1 through 9 are accepted (see bz2 for more information). Please try different compresslevel i.e. with zipfile.ZipFile(f'{directory_name}.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=0) as zipf: to

  8. Zip File Operations - Dive Into Python

    May 3, 2024 · Learn how to compress and bundle multiple files into a single ZIP archive in Python with this step-by-step guide.

  9. 5 Best Ways to Compress Files With zipfile Module in Python

    Mar 9, 2024 · For quick tasks where you want to zip a single file without fuss, Python allows you to compress files using a one-liner command. Here’s an example: zipfile.ZipFile('example.zip', 'w').write('document1.txt')

  10. How To Compress and Extract Zip Files with Python

    Apr 16, 2020 · In this How To article I demonstrate using Python to compress files into zip archives along with extracting files contained in a zip archive.

Refresh