回答編集履歴

2

d

2019/06/05 13:42

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -24,11 +24,15 @@
24
24
 
25
25
 
26
26
 
27
+ exists = Path(csv_path).exists()
28
+
29
+
30
+
27
31
  with open(csv_path, "a") as f:
28
32
 
29
33
  writer = csv.DictWriter(f, fieldnames=["in_flag", "t1"])
30
34
 
31
- if not Path(csv_path).exists():
35
+ if not exists:
32
36
 
33
37
  writer.writeheader() # ファイルが存在しない場合は、ヘッダーを書き込む。
34
38
 

1

d

2019/06/05 13:42

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -36,7 +36,7 @@
36
36
 
37
37
 
38
38
 
39
- with open("time.csv") as f:
39
+ with open(csv_path) as f:
40
40
 
41
41
  reader = csv.DictReader(f)
42
42