Ask coding questions

← Back to all posts
1
zip
SaraGrella (0)

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

Commentshotnewtop
2
JustARatherRidi (186)
  • First, make sure the repl you want to download is yours. If it isn't, change one character somewhere so that the repl is forked to your account.

  • Then click on these 3 dots at the top left of your screen:

  • In the drop down menu, Select 'Download as zip'

From there, once you've downloaded it, you can use a compressing tool like WinZip or WinRAR, or even an online extractor like this one to extract the files. And you're done!

Hope this helped, let me know if I lost you anywhere.

2
a5rocks (502)

@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.

2
JustARatherRidi (186)

@a5rocks As I understood it, I thought op was trying to download a repl as a zip file and extract a python file from it. But if the op was trying to use a python script to extract a file, then this is probably the way to do it. +1

1
a5rocks (502)

@JustARatherRidi yeah i though op was trying to download too, but didn't want to leave a possibility out. (plus i had extra time xd)

1
MATTHEWBECHTEL (121)

I’d answer but, I honestly don’t know.