How to use zipfile

Jesper Olsen jolsen at mailme.dk
Wed Nov 6 07:30:08 EST 2002


"Jack Lau" <jack98lau at hotmail.com> wrote in message news:<3dc8c6b3$1 at shknews01>...
> Hello,
> 
> I am a beginner to learn python. Could anyone tell me how to use zipfile. I
> want to zip a file like "a.txt" and zipped it into "abc.zip". Then how can I
> do ?
> 
> Thanks in advance!

Like this:

import zipfile
zf=zipfile.ZipFile("abc.zip", "w", zipfile.ZIP_DEFLATED)
zf.write("a.txt", "a.txt")


Cheers
Jesper



More information about the Python-list mailing list