zipfile and tarfile
Create and extract .zip and .tar(.gz) archives.
Beginner
import zipfile
with zipfile.ZipFile("logs.zip", "w", zipfile.ZIP_DEFLATED) as z:
for p in Path("logs").glob("*.csv"): z.write(p)
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.