write a program zip.py to create a zip file. The program should take the name of
ID: 3587696 • Letter: W
Question
write a program zip.py to create a zip file. The program should take the name of zip file and files to add to the zip file. Use import zipfile.class. In python please write a program zip.py to create a zip file. The program should take the name of zip file and files to add to the zip file. Use import zipfile.class. In python please write a program zip.py to create a zip file. The program should take the name of zip file and files to add to the zip file. Use import zipfile.class. In python pleaseExplanation / Answer
import os
import zipfile
def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file))
if __name__ == '__main__':
zipf = zipfile.ZipFile('Python.zip', 'w', zipfile.ZIP_DEFLATED)
zipdir('tmp/', zipf)
zipf.close()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.