import zipfile with zipfile.ZipFile('archive.zip', 'r') as zip: for name in zip.namelist(): print(name)
import zipfile with zipfile.ZipFile('myarchive.zip', 'w') as zip: zip.write('file1.txt') zip.write('file2.txt')- Here, we create a new archive file named `myarchive.zip` and use the `write()` method to add two files, `file1.txt` and `file2.txt`, to the archive. Package Library: zipfile (Built-in in Python)