只是来自Jeopardy JSON的问答

2024-04-16 12:12:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我下载了20万个危险问题问答。我觉得插入一些琐事机器人会很有趣。总之,它有50米大,我看不到断线。你知道吗

我只想把这个怪物的所有问题和答案拉到一个文件格式中,比如:

-- 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"}, 
 ...

Tags: ofthe答案answernumberdatevalueshow
1条回答
网友
1楼 · 发布于 2024-04-16 12:12:06

对于列表中的每个词典,获取'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

相关问题 更多 >