teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

追記

2020/05/15 04:13

投稿

jeanbiego
jeanbiego

スコア3966

answer CHANGED
@@ -10,4 +10,17 @@
10
10
  # value
11
11
  print(a[0]['children'][0]['test2'][0])
12
12
  # 12345678
13
+ ```
14
+
15
+ ```python
16
+ a = "[{'test': 'AND', 'children': [{'test3': 'value', 'test2': [12345678]}]}]"
17
+ exec("a="+a)
18
+ print(a)
19
+ # [{'test': 'AND', 'children': [{'test3': 'value', 'test2': [12345678]}]}]
20
+ print(a[0]['test'])
21
+ # AND
22
+ print(a[0]['children'][0]['test3'])
23
+ # value
24
+ print(a[0]['children'][0]['test2'][0])
25
+ # 12345678
13
26
  ```

1

追記

2020/05/15 04:13

投稿

jeanbiego
jeanbiego

スコア3966

answer CHANGED
@@ -1,5 +1,5 @@
1
- listの中にあるものは[]の中に数を、
1
+ listの中にあるものは[]の中にindex(整)を、
2
- dictの中にあるもの[]の中にkeyを入れて
2
+ dictの中にあるもの[]の中にkey(文字列)を入れて
3
3
  というのを繰り返せば取れます。
4
4
 
5
5
  ```python