質問編集履歴
1
コード変更とエラー表示の詳細
title
CHANGED
File without changes
|
body
CHANGED
@@ -16,4 +16,32 @@
|
|
16
16
|
for i in lines:
|
17
17
|
if lines[0] == #ある行の先頭が#で始まっていたらその行をすべて削除する
|
18
18
|
|
19
|
-
```
|
19
|
+
```
|
20
|
+
|
21
|
+
コードを書き直しましたが、エラーが表示されてしまいます。
|
22
|
+
```python
|
23
|
+
import sys
|
24
|
+
|
25
|
+
file = sys.argv
|
26
|
+
|
27
|
+
file1 = file[1]#これが読み込むファイル
|
28
|
+
|
29
|
+
file1 = open(file[1],'w')
|
30
|
+
|
31
|
+
lines = []
|
32
|
+
lines = file1.readlines()
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
for i in lines:
|
37
|
+
if not lines.startswitch("#"):
|
38
|
+
print(lines)
|
39
|
+
else:
|
40
|
+
print('')
|
41
|
+
|
42
|
+
```
|
43
|
+
エラー内容
|
44
|
+
Traceback (most recent call last):
|
45
|
+
File "ex04_4.py", line 16, in <module>
|
46
|
+
lines = file1.readlines()
|
47
|
+
io.UnsupportedOperation: not readable
|