Mega Code Archive

 
Categories / Python Tutorial / File
 

Adding Files to a ZIP File

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()