1
zip
SaraGrella (0)

how can i zip a file and download it in a .py version?

You are viewing a single comment. View All
2
a5rocks (501)

@JustARatherRidi

import zlib

with open('file.txt', 'rb') as f:
  a = zlib.compress(f.read(), level=9)

with open('file.zip', 'wb') as f
  f.write(a)

print('Done!')

If you want to make specific files a zip file. Please keep in mind I'm only putting this here so it's a more complete answer.