回答編集履歴
1
修正
test
CHANGED
@@ -10,33 +10,35 @@
|
|
10
10
|
|
11
11
|
```Python
|
12
12
|
|
13
|
-
import
|
13
|
+
from pathlib import Path
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
-
src_file = 'test.txt'
|
17
|
+
src_file = Path('test.txt')
|
18
18
|
|
19
|
-
dst_file = '_
|
19
|
+
dst_file = Path('_work.tmp')
|
20
20
|
|
21
21
|
|
22
22
|
|
23
|
-
with
|
23
|
+
with src_file.open() as fin, \
|
24
24
|
|
25
|
-
|
25
|
+
dst_file.open(mode='x') as fout:
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
-
fout.write(
|
29
|
+
fout.write(
|
30
30
|
|
31
|
-
fin.read().replace('テスト', '試み')
|
31
|
+
fin.read().replace('テスト', '試み')
|
32
32
|
|
33
|
-
)
|
33
|
+
)
|
34
34
|
|
35
35
|
|
36
36
|
|
37
|
-
os.replace(
|
38
37
|
|
38
|
+
|
39
|
-
|
39
|
+
dst_file.replace(
|
40
|
+
|
41
|
+
src_file
|
40
42
|
|
41
43
|
)
|
42
44
|
|