URL: http://www.devshed.com/c/a/Python/Python-UnZipped/

Zipping and unzipping a file in Python is child-play. It can't get much easier than this. Well, in Windows you can highlight a couple of files and right-click and select from the WinZip menu. Here's how to do it in Python:


>>> import zipfile
>>> zip = zipfile.ZipFile('Python.zip', 'w')
>>> zip.write('file1.txt')
>>> zip.write('file2.gif')
>>> zip.close()

Still confused? Read this article for "Dev Shed"n:http://www.devshed.com/ then. The article includes some more advanced uses as well.

Comments

Your email will never ever be published.

Previous:
Deep sea fish, lots of pictures March 11, 2004 Misc. links
Next:
To readline() or readlines() March 12, 2004 Python
Related by category:
A Python dict that can report which keys you did not use June 12, 2025 Python
Faster way to sum an integer series in Python August 28, 2025 Python
Combining Django signals with in-memory LRU cache August 9, 2025 Python
Native connection pooling in Django 5 with PostgreSQL June 25, 2025 Python
Related by keyword:
Fastest way to unzip a zip file in Python January 31, 2018 Python
Zipping files is appending by default - Watch out! October 4, 2023 Linux
Unzip benchmark on AWS EC2 c3.large vs c4.large November 29, 2017 Python, Linux, Mozilla, Go
A neat trick to zip a git repo with a version number September 1, 2017 Linux, Web development