回答編集履歴
1
追記
test
CHANGED
@@ -35,3 +35,25 @@
|
|
35
35
|
"""
|
36
36
|
|
37
37
|
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
ちょっと違うバージョン。 [Wandbox](https://wandbox.org/permlink/4bM6y9Xz7kPzwveD)
|
42
|
+
|
43
|
+
```Python
|
44
|
+
|
45
|
+
with open('sample.txt') as f:
|
46
|
+
|
47
|
+
header, *lines = [
|
48
|
+
|
49
|
+
'{0}: {1}'.format(i, line.rstrip()) for i, line
|
50
|
+
|
51
|
+
in enumerate(f.readlines(), start=1)
|
52
|
+
|
53
|
+
]
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
print(*lines, sep='\n')
|
58
|
+
|
59
|
+
```
|