【问题标题】:How to compress files as password protected archive using Python如何使用 Python 将文件压缩为受密码保护的存档
【发布时间】:2017-02-23 20:49:39
【问题描述】:
有没有办法将gzip 或zipfile 压缩为受密码保护的存档?
这是一个示例代码,说明如何在没有密码保护的情况下归档文件:
import gzip, shutil
filepath = r'c:\my.log'
with gzip.GzipFile(filepath + ".gz", "w") as gz:
with open(filepath) as with_open_file:
shutil.copyfileobj(with_open_file, gz)
import zipfile
zf = zipfile.ZipFile(filepath + '.zip', 'w')
zf.write(filepath)
zf.close()
【问题讨论】:
那么您要求的是其他人阅读这些功能的手册?
The gzip format does not support password protection.
标签:
python
passwords
gzip
archive
zipfile
|