Script to make Windows XP-readable ZIP file

softwindow softwindow at gmail.com
Fri May 19 05:54:35 CEST 2006


my code can work, like below:

import os
import zipfile
z =
zipfile.ZipFile(r"c:\text.zip",mode="w",compression=zipfile.ZIP_DEFLATED)
cwd = os.getcwd()
try:
    for dirpath,dirs,files in os.walk(cwd):
        for file in files:
            z_path = os.path.join(dirpath,file)
            z.write(z_path)
    z.close()
finally:
    if z:
        z.close()

that is true
but the archive  include the absolute path .
can you give me a way to build it with relative path.




More information about the Python-list mailing list