如何从json获取以下两个列表?

时间:2017-04-05 00:37:07

标签: json python-3.x

您好我正在尝试使用以下结构解析json:

{"Question":["what is this?","this is another question"], "Topic": ["Web pages","another topic"]}

我想获得两个名单,

questions=["what is this?","this is another question"]
topics=["Web pages","another topic"]

由于我是初学者解析json,我无法尝试:

>>> with open('stack.json','r') as f:
...     data = json.load(f)
... 
>>> for element in data:
...     print(element)
... 

但是我得到了:

Question
Topic

所以我想感谢支持获得前两个名单。

1 个答案:

答案 0 :(得分:1)

要获取元素,必须使用字典中的键

linear to polynomial - time and space complexity

输出:

quadratic and/or exponential - time and space complexities