回答編集履歴

2

修正

2018/10/11 07:44

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  with open('input/books.csv', encoding='utf-8') as fin, \
6
6
 
7
- with open('output/book_python.csv', 'w', encoding='utf-8') as fout:
7
+ open('output/book_python.csv', 'w', encoding='utf-8') as fout:
8
8
 
9
9
 
10
10
 
@@ -21,3 +21,13 @@
21
21
 
22
22
 
23
23
  追記モード`a`は少し使いづらい印象です。
24
+
25
+
26
+
27
+ > PyQというサイトの問題なのですがoutput/book_python.csvの中身を消した状態で一度だけ実行をしても2回ずつ書き込まれてしまい間違いと表示がされてしまいます。
28
+
29
+ コード自体は間違いはないのでしょうか?
30
+
31
+
32
+
33
+ 問題ないと思いますが。[Wandbox](https://wandbox.org/permlink/jObBJ44LWsr823xc)

1

修正

2018/10/11 07:44

投稿

LouiS0616
LouiS0616

スコア35660

test CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  with open('input/books.csv', encoding='utf-8') as fin, \
6
6
 
7
- with open('output/book_python.csv', 'a', encoding='utf-8') as fout:
7
+ with open('output/book_python.csv', 'w', encoding='utf-8') as fout:
8
8
 
9
9
 
10
10
 
@@ -17,3 +17,7 @@
17
17
  fout.write(row)
18
18
 
19
19
  ```
20
+
21
+
22
+
23
+ 追記モード`a`は少し使いづらい印象です。