質問編集履歴
2
code
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,11 +26,7 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
|
29
|
+
```python 3.7.1
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
1)<最後の1行のみ書き込まれるコード>
|
34
30
|
|
35
31
|
f = open("ファイル名","r")
|
36
32
|
|
@@ -62,11 +58,13 @@
|
|
62
58
|
|
63
59
|
print(f.read())
|
64
60
|
|
61
|
+
```
|
65
62
|
|
66
63
|
|
67
64
|
|
68
65
|
|
66
|
+
|
69
|
-
|
67
|
+
```python 3.7.1
|
70
68
|
|
71
69
|
f = open("ファイル名","r")
|
72
70
|
|
@@ -95,6 +93,8 @@
|
|
95
93
|
with open(path_w, mode='w') as f:
|
96
94
|
|
97
95
|
f.write(list)
|
96
|
+
|
97
|
+
```
|
98
98
|
|
99
99
|
|
100
100
|
|
1
最後の1行のみ書き込まれるコード、修正したがエラーが出るコード
test
CHANGED
File without changes
|
test
CHANGED
@@ -27,6 +27,46 @@
|
|
27
27
|
|
28
28
|
|
29
29
|
言語:python 3.7.1
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
1)<最後の1行のみ書き込まれるコード>
|
34
|
+
|
35
|
+
f = open("ファイル名","r")
|
36
|
+
|
37
|
+
while True:
|
38
|
+
|
39
|
+
line = f.readline()
|
40
|
+
|
41
|
+
if not line:
|
42
|
+
|
43
|
+
break
|
44
|
+
|
45
|
+
oline = line.replace('\r\n', ',')
|
46
|
+
|
47
|
+
print(oline)
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
path_w = 'ファイルパス'
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
with open(path_w, mode='w') as f:
|
56
|
+
|
57
|
+
f.write(oline)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
with open(path_w) as f:
|
62
|
+
|
63
|
+
print(f.read())
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
2)<list.appendでエラーが出るコード>
|
30
70
|
|
31
71
|
f = open("ファイル名","r")
|
32
72
|
|