zipfile
Stdlib — CompressionPython 2.0+Intermediate
Read and write ZIP archives
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
- Dependencies
- None — Python Standard Library
- Install
Included with Python
Learn by Difficulty
Quick Example
python
import zipfile from io import BytesIO # Create zip in memory buf = BytesIO() with zipfile.ZipFile(buf, "w") as zf: zf.writestr("hello.txt", "Hello, World!") zf.writestr("data.txt", "Some data here") # Read zip buf.seek(0) with zipfile.ZipFile(buf, "r") as zf: print(zf.namelist()) print(zf.read("hello.txt"))
The zipfile module is part of Python's standard library. Read and write ZIP archives.
Try in PlaygroundTags
stdlibcompressionarchive