Created
February 11, 2018 08:10
-
-
Save munsiwoo/b4d9c56efda04aa24b37cd634ea9cf3a to your computer and use it in GitHub Desktop.
python zipfile lib (compress example)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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