回答編集履歴

3

d

2019/06/17 07:27

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -25,3 +25,57 @@
25
25
  myfile_obj.close
26
26
 
27
27
  ```
28
+
29
+
30
+
31
+ ## 追記
32
+
33
+
34
+
35
+ > AES-256bitにしていて、この暗号強度最高にしているのが原因なのでしょうか??
36
+
37
+
38
+
39
+ 暗号化方式 AES は Python の標準ライブラリ zipfile は対応してないようです。
40
+
41
+ AES-256 で圧縮したところ、同じエラーが出ました。
42
+
43
+
44
+
45
+ AES に対応した pyzipper というライブラリがあるようなので、こちらをお使いください。
46
+
47
+ `pip install pyzipper` でインストールできます。
48
+
49
+
50
+
51
+ [danifus/pyzipper: Python zipfile extensions](https://github.com/danifus/pyzipper)
52
+
53
+
54
+
55
+ 使い方は zipfile と全く同じです。
56
+
57
+
58
+
59
+ ```python
60
+
61
+ import glob
62
+
63
+ import pyzipper
64
+
65
+
66
+
67
+ password = b"rabbit"
68
+
69
+
70
+
71
+ for path in glob.glob("*.zip"):
72
+
73
+ print(f"extracting... {path}")
74
+
75
+
76
+
77
+ with pyzipper.AESZipFile(path) as f:
78
+
79
+ f.extractall(pwd=password)
80
+
81
+ ```

2

d

2019/06/17 07:27

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -4,20 +4,24 @@
4
4
 
5
5
  ```diff
6
6
 
7
- - for filename in myfile:
7
+ import zipfile, os
8
8
 
9
- - myfile_obj = zipfile.ZipFile(filename)
9
+ myfile =[]
10
10
 
11
- - myfile_obj.extractall(pwd="rabbit".encode("ascii"))
11
+ for filename in os.listdir('.'):
12
12
 
13
- - myfile_obj.close
13
+ if filename.endswith('.zip'):
14
14
 
15
- + for filename in myfile:
15
+ myfile.append(filename)
16
16
 
17
- + myfile_obj = zipfile.ZipFile(filename)
18
17
 
19
- + myfile_obj.extractall(pwd="rabbit".encode("ascii"))
20
18
 
19
+ for filename in myfile:
20
+
21
+ myfile_obj = zipfile.ZipFile(filename)
22
+
23
+ myfile_obj.extractall(pwd='rabbit'.encode('ascii'))
24
+
21
- + myfile_obj.close
25
+ myfile_obj.close
22
26
 
23
27
  ```

1

d

2019/06/17 06:58

投稿

tiitoi
tiitoi

スコア21956

test 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
 
4
4