Answer the question
In order to leave comments, you need to log in
Why is a password not set for the archive?
import zipfile
z = zipfile.ZipFile('BEK.zip', 'w')
z.setpassword(b"1234")
for root, dirs, files in os.walk('/path/to/file'): # Список всех файлов и папок в директории folder
for file in files:
z.write(os.path.join(root,file)) # Создание относительных путей и запись файлов в архив
z.close()
Answer the question
In order to leave comments, you need to log in
The zipfile library cannot put a password on an archive. The setpassword method is needed to set a password for extracting encrypted files.
In your case, you need to use pyminizip.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question