回答編集履歴
1
読み込み処理追加
test
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
書き込み
|
2
|
+
|
3
|
+
|
4
|
+
|
1
5
|
```python
|
2
6
|
|
3
7
|
with open("count.txt", "w") as f:
|
@@ -5,3 +9,23 @@
|
|
5
9
|
print(count, file=f)
|
6
10
|
|
7
11
|
```
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
読み込み
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
```python
|
20
|
+
|
21
|
+
try:
|
22
|
+
|
23
|
+
with open("count.txt") as f:
|
24
|
+
|
25
|
+
count = int(f.read().strip())
|
26
|
+
|
27
|
+
except (FileNotFoundError, ValueError):
|
28
|
+
|
29
|
+
count = 0
|
30
|
+
|
31
|
+
```
|