回答編集履歴

1

修正

2018/05/09 10:02

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -10,33 +10,35 @@
10
10
 
11
11
  ```Python
12
12
 
13
- import os
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 = '_dst.tmp'
19
+ dst_file = Path('_work.tmp')
20
20
 
21
21
 
22
22
 
23
- with open(src_file) as fin, \
23
+ with src_file.open() as fin, \
24
24
 
25
- open(dst_file, mode='x') as fout:
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
- dst_file, src_file
39
+ dst_file.replace(
40
+
41
+ src_file
40
42
 
41
43
  )
42
44