0

I'm trying to zip a file which is currently in a directory of mine, i have used the code below to achieve that to no avail.

i was told to use zipfile and it doesnt seem to be working for me, it creates an empty zip file.

19:52 ~/mysite/static/downloads $ ls                                                
2830854  5378949 
>>> import zipfile                                                                  
>>> import os                                                                       
>>> os.getcwd()                                                                     
'/home/KindredBay/mysite/static/downloads'                                          
>>> zip = zipfile.ZipFile('test.zip', 'w')
>>> zip                                                                             
<zipfile.ZipFile object at 0x7f52f2150e10>                                          
>>> zip.write(os.getcwd()+'/', '2830854')
>>>                                                                                 
[5]+  Stopped                 python                                                
19:56 ~/mysite/static/downloads $ ls                                                
2830854  5378949  test.zip                                                          
19:56 ~/mysite/static/downloads $   
Ali
  • 39
  • 6

0 Answers0