【发布时间】:2013-11-11 10:13:54
【问题描述】:
我的 JSON 字典如下所示:
{
"end": 1,
"results": [
{
"expired": false,
"tag": "search"
},
{
"span": "text goes here"
}
],
"totalResults": 1
}
这是这条线的产品:
tmp_response['results'].append({'span':"text goes here"})
我的目标是让“span”键进入“结果”列表。当 totalResults > 1 时,这是必需的。
{
"end": 1,
"results": [
{
"expired": false,
"tag": "search",
"span": "text goes here"
},
],
"totalResults": 1
}
我尝试了几种方法,例如使用“dictname.update”,但这会覆盖“结果”中的现有数据。
【问题讨论】:
-
您要更新第一个结果还是所有结果?
标签: python json list python-2.7 dictionary