decompress zipped files on Windows

Alan G Isaac aisaac at american.edu
Thu Sep 23 16:27:32 EDT 2004


I have an .zip archive of compressed files that
I want to decompress.  Using the zipfile module,
I tried
z=zipfile.ZipFile(local.zip)
for zname in z.namelist():
        localtxtfile='c:/puthere/'+zname
        f=open(localtxtfile,'w')
        f.write(z.read(zname))
        f.close

The original files were all plain text,
created on an unspecified platform.
The files I decompressed this way contain
*two successive* carriage returns
(ASCII 13) at the end of each line.
If I change 'w' to 'wb' I get only one.

Why is this extra carriage return added?
My original guess was the using 'w' instead
of 'wb' would be the right action, since the
platform for the original files is unspecified.

Thanks,
Alan Isaac





More information about the Python-list mailing list