回答編集履歴
3
d
answer
CHANGED
@@ -11,4 +11,31 @@
|
|
11
11
|
myfile_obj = zipfile.ZipFile(filename)
|
12
12
|
myfile_obj.extractall(pwd='rabbit'.encode('ascii'))
|
13
13
|
myfile_obj.close
|
14
|
+
```
|
15
|
+
|
16
|
+
## 追記
|
17
|
+
|
18
|
+
> AES-256bitにしていて、この暗号強度最高にしているのが原因なのでしょうか??
|
19
|
+
|
20
|
+
暗号化方式 AES は Python の標準ライブラリ zipfile は対応してないようです。
|
21
|
+
AES-256 で圧縮したところ、同じエラーが出ました。
|
22
|
+
|
23
|
+
AES に対応した pyzipper というライブラリがあるようなので、こちらをお使いください。
|
24
|
+
`pip install pyzipper` でインストールできます。
|
25
|
+
|
26
|
+
[danifus/pyzipper: Python zipfile extensions](https://github.com/danifus/pyzipper)
|
27
|
+
|
28
|
+
使い方は zipfile と全く同じです。
|
29
|
+
|
30
|
+
```python
|
31
|
+
import glob
|
32
|
+
import pyzipper
|
33
|
+
|
34
|
+
password = b"rabbit"
|
35
|
+
|
36
|
+
for path in glob.glob("*.zip"):
|
37
|
+
print(f"extracting... {path}")
|
38
|
+
|
39
|
+
with pyzipper.AESZipFile(path) as f:
|
40
|
+
f.extractall(pwd=password)
|
14
41
|
```
|
2
d
answer
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
解凍する zip ファイルのリスト `myfile` を作成してから、そのリストを iterate するので、`for filename in myfile` 以下の4行のインデントは1つ下げるべきではないでしょうか。
|
2
2
|
|
3
3
|
```diff
|
4
|
+
import zipfile, os
|
5
|
+
myfile =[]
|
4
|
-
|
6
|
+
for filename in os.listdir('.'):
|
7
|
+
if filename.endswith('.zip'):
|
5
|
-
|
8
|
+
myfile.append(filename)
|
6
|
-
|
9
|
+
|
7
|
-
- myfile_obj.close
|
8
|
-
|
10
|
+
for filename in myfile:
|
9
|
-
|
11
|
+
myfile_obj = zipfile.ZipFile(filename)
|
10
|
-
|
12
|
+
myfile_obj.extractall(pwd='rabbit'.encode('ascii'))
|
11
|
-
|
13
|
+
myfile_obj.close
|
12
14
|
```
|
1
d
answer
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
解凍する zip ファイルのリスト `myfile` を作成してから、そのリストを iterate するので、`for filename in myfile` のインデントは1つ下げるべきではないでしょうか。
|
1
|
+
解凍する zip ファイルのリスト `myfile` を作成してから、そのリストを iterate するので、`for filename in myfile` 以下の4行のインデントは1つ下げるべきではないでしょうか。
|
2
2
|
|
3
3
|
```diff
|
4
4
|
- for filename in myfile:
|