回答編集履歴
2
追記
test
CHANGED
@@ -11,3 +11,31 @@
|
|
11
11
|
f.write(','.join(map(str, row)) + '\n')
|
12
12
|
|
13
13
|
```
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
---
|
18
|
+
|
19
|
+
何も考えずに変数の名前をstrとかlistとかにするのは非常に危険です。
|
20
|
+
|
21
|
+
```Python
|
22
|
+
|
23
|
+
>>> str(1)
|
24
|
+
|
25
|
+
'1'
|
26
|
+
|
27
|
+
>>> str = 'hoge'
|
28
|
+
|
29
|
+
>>> str(1)
|
30
|
+
|
31
|
+
Traceback (most recent call last):
|
32
|
+
|
33
|
+
File "<stdin>", line 1, in <module>
|
34
|
+
|
35
|
+
TypeError: 'str' object is not callable
|
36
|
+
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
このエラーの理由はわかりますか?
|
1
修正
test
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
data =[[0,0,0,0,0,0],[0,0,0,0,0,0],[0,0,0,0,0,0]]
|
6
6
|
|
7
|
-
with open(
|
7
|
+
with open(dir, "w") as f:
|
8
8
|
|
9
9
|
for row in data:
|
10
10
|
|