Script to make Windows XP-readable ZIP file

softwindow softwindow at gmail.com
Thu May 18 23:54:35 EDT 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