来自 Jeopardy JSON 的问答

古怪模式开启

我下载了 Jeopardy 问题的 200k Q/A。我认为插入一些琐事机器人会很有趣。无论如何,它的大小为 50M,我可以看到没有换行符。

我只想将这个怪物的所有问题和答案提取到一个文件格式中,例如:

-- question
 - answer

这是文件的一部分。我知道我不能一行一行地进行,我知道我不能将整个内容加载到内存中。但是,我也知道我想要的是后面引号中的第一件事,"question":而答案是"answer":.

[{"category": "HISTORY", "air_date": "2004-12-31", "question": "'For the last 8 years of his life, Galileo was under house arrest for espousing this man's theory'", "value": "$200", "answer": "Copernicus", "round": "Jeopardy!", "show_number": "4680"},
 {"category": "ESPN's TOP 10 ALL-TIME ATHLETES", "air_date": "2004-12-31", "question": "'No. 2: 1912 Olympian; football star at Carlisle Indian School; 6 MLB seasons with the Reds, Giants & Braves'", "value": "$200", "answer": "Jim Thorpe", "round": "Jeopardy!", "show_number": "4680"},
 {"category": "EVERYBODY TALKS ABOUT IT...", "air_date": "2004-12-31", "question": "'The city of Yuma in this state has a record average of 4,055 hours of sunshine each year'", "value": "$200", "answer": "Arizona", "round": "Jeopardy!", "show_number": "4680"}, 
 ...
戴夫沃兹

对于列表中的每个字典,获取'question''answer'键:

for l in d:
    print l['question'], l['answer']

输出:

'For the last 8 years of his life, Galileo was under house arrest for espousing this man's theory' Copernicus
'No. 2: 1912 Olympian; football star at Carlisle Indian School; 6 MLB seasons with the Reds, Giants & Braves' Jim Thorpe
'The city of Yuma in this state has a record average of 4,055 hours of sunshine each year' Arizona

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章