How to use zipfile

Jack Lau jack98lau at hotmail.com
Wed Nov 6 20:36:45 EST 2002


Thank you very much!

"Thorsten Goertz" <thorsten at goertz.com> ¼¶¼g©ó¶l¥ó·s»D
:baad20ed.0211060458.2753d817 at posting.google.com...
> I use it in this way:
>
> import zipfile
> archive = zipfile.ZipFile( "abc.zip", "w", zipfile.ZIP_DEFLATED )
> source = "a.txt"
> destination = source
> archive.write( source, destination )
> archive.close( )
>
> I'd prefer to create a "virtual directory" in the root of the zipfile
> (with destination = os.path.join( "abc", source ). Archives without
> this virtual root directory sometimes caused trouble to me. I unzipped
> an archive and contaminated the current directory with a lot of files
> that I expected to be in a subdir that has been named like the
> archive...
>
>
> "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!





More information about the Python-list mailing list