import zipfile import os file = open('myfile','w') for b in range (1,3): for a in range (1,1000000): file.write('aaaaaaaaaaaaa') file.close() print "file created" zout = zipfile.ZipFile('myzip.zip', "w") zout.write('myfile') zout.close() print "zip created" print "try to unzip" zip = zipfile.ZipFile('myzip.zip') dir = "output" for name in zip.namelist(): if name.endswith('/'): os.mkdir(os.path.join(dir, name)) else : outfile = open(os.path.join(dir,name), 'wb') outfile.write(zip.read(name)) outfile.close() print "unzip done"