我有與拉鍊特定文件夾中的每個文件壓縮代碼,但我想用7zip的壓縮,所以怎麼辦呢?如何使用7zip的,而不是壓縮壓縮,密碼變更
這是我到目前爲止有:
for date in dict_date:#zipping folders and get same name like the folder
with ZipFile(os.path.join(src, '{0}.7z'.format(date)), 'w') as myzip:
for subFolder in dict_date[date]:
for fil in os.listdir(os.path.join(src, date, subFolder)):
if not fil.endswith('.7z'):
myzip.write(os.path.join(src, date, subFolder, fil))
更改文件擴展不會改變使用的文件格式,也沒有壓縮算法。您將不得不通過子進程調用來調用7zip命令行客戶端。 – 2012-07-13 08:14:47
我知道,我需要一個例子。 – zeromancer 2012-07-13 09:01:10