回答編集履歴
3
コード変更
test
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
File "<stdin>", line 1, in <module>
|
12
12
|
TypeError: writerows() takes exactly one argument (3 given)
|
13
13
|
>>> csv.writer(open('t.csv', 'w')).writerows([[1, 2, 3]])
|
14
|
-
>>>
|
14
|
+
>>> open('t.csv').read()
|
15
|
-
1,2,3
|
15
|
+
'1,2,3\n'
|
16
16
|
```
|
17
17
|
|
2
コード追記
test
CHANGED
@@ -3,3 +3,15 @@
|
|
3
3
|
「writerows()はひとつ(one)の引数(argument)しかとりません (なのに3つ与えられとる)」
|
4
4
|
|
5
5
|
ということは、`writerows([[1, 2, 3]])` のように書くべきところを `writerows(1, 2, 3)` とか書いているのでは?
|
6
|
+
|
7
|
+
```py
|
8
|
+
>>> import csv
|
9
|
+
>>> csv.writer(open('t.csv', 'w')).writerows(1, 2, 3)
|
10
|
+
Traceback (most recent call last):
|
11
|
+
File "<stdin>", line 1, in <module>
|
12
|
+
TypeError: writerows() takes exactly one argument (3 given)
|
13
|
+
>>> csv.writer(open('t.csv', 'w')).writerows([[1, 2, 3]])
|
14
|
+
>>> print(open('t.csv').read())
|
15
|
+
1,2,3
|
16
|
+
```
|
17
|
+
|
1
修正
test
CHANGED
@@ -2,4 +2,4 @@
|
|
2
2
|
|
3
3
|
「writerows()はひとつ(one)の引数(argument)しかとりません (なのに3つ与えられとる)」
|
4
4
|
|
5
|
-
ということは、`writerows([1, 2, 3])`
|
5
|
+
ということは、`writerows([[1, 2, 3]])` のように書くべきところを `writerows(1, 2, 3)` とか書いているのでは?
|