I want to create a file .zip in python that includes an entire folder + another file,how can i make it?
files.zip:
|-mydir
|-file.txt
Thanks
I want to create a file .zip in python that includes an entire folder + another file,how can i make it?
files.zip:
|-mydir
|-file.txt
Thanks
Solved. In according with zip documentation
with ZipFile('Your_zip_file.zip','w') as zip:
# writing each file one by one
for file in os.listdir(str(Path("folder_to_zip/"))):
zip.write('folder_to_zip/'+str(file))
zip.close()
Use:
Hope this will be helpful for others.