質問編集履歴
2
q
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
ほそく
|
2
|
+
|
3
|
+
```ここに言語を入力
|
4
|
+
#list リスト型の場合
|
5
|
+
if isinstance(variable_field,list) == True:
|
6
|
+
print("csv-outpiut:list ",type(variable_field))
|
7
|
+
writer.writerow(fixed_field + variable_field) # 固定項目+可変項目
|
8
|
+
|
9
|
+
#dict 辞書型の場合
|
10
|
+
elif isinstance(variable_field,dict) == True:
|
11
|
+
print("csv-outpiut:dict ",type(variable_field))
|
12
|
+
|
13
|
+
lst = []
|
14
|
+
for e in variable_field.items():
|
15
|
+
lst.extend(e)
|
16
|
+
|
17
|
+
print("lst :",lst)
|
18
|
+
writer.writerow(fixed_field + lst) # 固定項目+可変項目
|
19
|
+
|
20
|
+
#タプル型の場合
|
21
|
+
elif isinstance(variable_field,tuple) == True:
|
22
|
+
print("csv-outpiut:tuple ",type(variable_field))
|
23
|
+
listed_var = list(variable_field)
|
24
|
+
writer.writerow(fixed_field + listed_var) # 固定項目+可変項目
|
25
|
+
else:
|
26
|
+
print("csv-outpiut:other ------------------e-r-r-o-r-e-r-r-o-r-e-r-",type(variable_field))
|
27
|
+
```
|
28
|
+
|
29
|
+
|
30
|
+
|
1
31
|
おせわになります。初心者です。
|
2
32
|
辞書型データを並び順は同じで配列型リスト型に変換するには
|
3
33
|
どのように指定すべきでしょうか?
|
1
s
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,4 +15,7 @@
|
|
15
15
|
ためしたこと
|
16
16
|
listed_var = list(variable_field)
|
17
17
|
|
18
|
-
よろしくお願いします
|
18
|
+
よろしくお願いします
|
19
|
+
|
20
|
+
参考サイト
|
21
|
+
http://ututel.blog121.fc2.com/blog-entry-45.html
|