Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import zipfile
  2. import os
  3.  
  4.  
  5. with zipfile.ZipFile("testing.zip", 'a') as zip_file:
  6. for root, dirs, files in os.walk("test_dir"):
  7. for local_file in files:
  8. zip_file.write(os.path.join(root, local_file))
  9.  
  10.  
  11. print("Created Zip with Python")
  12. with zipfile.ZipFile('testing.zip') as zip_file:
  13. list = zip_file.infolist()
  14. for item in list:
  15. print(item.filename)
  16.  
  17. print("Zip created with 7Zip")
  18. with zipfile.ZipFile('test_dir.zip') as zip_file:
  19. list = zip_file.infolist()
  20. for item in list:
  21. print(item.filename)
  22.  
  23. Created Zip with Python
  24. test_dir/A Test Doc.txt
  25.  
  26. Zip created with 7Zip
  27. test_dir/
  28. test_dir/A Test Doc.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement