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:
How I run standalone Python in 2025 January 14, 2025 Python
How to resolve a git conflict in poetry.lock February 7, 2020 Python
get in JavaScript is the same as property in Python February 13, 2025 Python
Best practice with retries with requests April 19, 2017 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