回答編集履歴

1

無駄な部分を削除

2021/01/06 14:22

投稿

ppaul
ppaul

スコア24666

test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  >>> with zipfile.ZipFile('A.zip').open('B.zip') as b:
16
16
 
17
- ... B = zipfile.ZipFile(io.BytesIO(b.read()))
17
+ ... B = zipfile.ZipFile(b)
18
18
 
19
19
  ... print(B.namelist())
20
20
 
@@ -46,25 +46,13 @@
46
46
 
47
47
  >>> with A.open('B.zip') as b:
48
48
 
49
- ... binary_b = b.read()
49
+ ... B = zipfile.ZipFile(b)
50
50
 
51
51
  ...
52
52
 
53
- >>> print(binary_b)
54
-
55
- b'PK\x03\x04\x14\x00\x00\x00\x00\x00\xe2\xb3&RC\xbe\xb7\xe8\x01\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00a.txtaPK\x03\x04\x14\x00\x00\x00\x00\x00\xe7\xb3&R\xf9\xef\xbeq\x01\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00b.txtbPK\x01\x02\x14\x00\x14\x00\x00\x00\x00\x00\xe2\xb3&RC\xbe\xb7\xe8\x01\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\x00\x00\x00\x00\x00\x00a.txtPK\x01\x02\x14\x00\x14\x00\x00\x00\x00\x00\xe7\xb3&R\xf9\xef\xbeq\x01\x00\x00\x00\x01\x00\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x01\x00 \x00\x00\x00$\x00\x00\x00b.txtPK\x05\x06\x00\x00\x00\x00\x02\x00\x02\x00f\x00\x00\x00H\x00\x00\x00\x00\x00'
56
-
57
- >>> f_b = io.BytesIO(binary_b)
58
-
59
- >>> print(f_b)
60
-
61
- <_io.BytesIO object at 0x0000021A3830FA40>
62
-
63
- >>> B = zipfile.ZipFile(f_b)
64
-
65
53
  >>> print(B)
66
54
 
67
- <zipfile.ZipFile file=<_io.BytesIO object at 0x0000021A3830FA40> mode='r'>
55
+ <zipfile.ZipFile file=<zipfile.ZipExtFile [closed]> mode='r'>
68
56
 
69
57
  >>> print(B.namelist())
70
58