Adding Files to a ZIP File : zip file « File « Python Tutorial






import os
import zipfile

tFile = zipfile.ZipFile("files.zip", 'w')

files = os.listdir(".")
for f in files:
    tFile.write(f)

#List archived files
for f in tFile.namelist():
    print "Added %s" % f


tFile.close()








12.25.zip file
12.25.1.Adding Files to a ZIP File
12.25.2.Retrieving Files from a ZIP File