Skip to content

Is there a way to delete zip archive comments in python?

I have multiple zip archives all with a similar comment.

Is there a way to delete the comment from the archives with python and use it over multiple archives with similar comment?

What I have tried with single archive

import zipfile
archive = zipfile.ZipFile('', 'r')
del archive.comment

This is not working. Comment is not getting deleted in the archive, plus I want this to work on multiple archives in the same directory.



You are opening the zipfile in read mode with ‘r’ parameter. Use a mode that enables you to modify the file. Then set comment to ” instead of deleting it.

User contributions licensed under: CC BY-SA
1 People found this is helpful