Skip to content

Instantly share code, notes, and snippets.

@munsiwoo
Created February 11, 2018 08:10
Show Gist options
  • Save munsiwoo/b4d9c56efda04aa24b37cd634ea9cf3a to your computer and use it in GitHub Desktop.
Save munsiwoo/b4d9c56efda04aa24b37cd634ea9cf3a to your computer and use it in GitHub Desktop.
python zipfile lib (compress example)
import zipfile, string
from random import choice
# made by munsiwoo
def randGenerator(size=6, chars=string.ascii_uppercase + string.digits) :
return ''.join(choice(chars) for x in range(size))
fileName = "compress.txt"
packName = "./" + randGenerator() + ".zip"
zip = zipfile.ZipFile(packName, 'w');
zip.write(fileName, compress_type=zipfile.ZIP_DEFLATED)
fileName = packName
x = 0
while(x < 10) :
packName = "./" + randGenerator() + ".zip"
print(packName)
zip = zipfile.ZipFile(packName, 'w');
zip.write(fileName, compress_type=zipfile.ZIP_DEFLATED)
fileName = packName
x += 1
zip.close()
print("Last : " + fileName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment