質問編集履歴
3
プログラムの誤記修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
openコマンドでできないか試行錯誤(その1)
|
44
44
|
```python3
|
45
45
|
with tarfile.open("aaa.tgz")as t:
|
46
|
-
with
|
46
|
+
with t.open("aaa/ccc.tgz")as tt: ・・・エラー発生
|
47
47
|
with tt.open("ccc/d.txt")as ttt:
|
48
48
|
result = fff.read()
|
49
49
|
```
|
2
プログラムの誤記修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,8 +31,8 @@
|
|
31
31
|
### 発生している問題・エラーメッセージ
|
32
32
|
ZipFileと同じ形式でプログラムしたが、エラーが発生した。
|
33
33
|
```python3
|
34
|
-
with tarfile.TarFile("aaa.
|
34
|
+
with tarfile.TarFile("aaa.tgz")as t: ・・・エラー発生
|
35
|
-
with t.open("aaa/ccc.
|
35
|
+
with t.open("aaa/ccc.tgz") as tt:
|
36
36
|
with tarfile.TarFile(tt).open("d.txt") as ttt:
|
37
37
|
result = ttt.read()
|
38
38
|
```
|
1
フォルダのインデントを修正して見た目を良くした
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
---┣b.txt
|
9
9
|
---┗ccc.tgz
|
10
10
|
------┗cccフォルダ
|
11
|
-
------┣c.txt
|
11
|
+
---------┣c.txt
|
12
|
-
------┗d.txt ・・・読みたいファイル
|
12
|
+
---------┗d.txt ・・・読みたいファイル
|
13
13
|
|
14
14
|
zipの場合、ZipFileオブジェクトを使えば開けました。
|
15
15
|
ただ今回のTarFileオブジェクトでは、エラーが発生します。
|