0

我正在使用 Twitter API 和 python,当我尝试合并检索到的 JSON 页面时遇到问题。

为每个请求检索到的 JSON 的结构是:

{
  "previous_cursor": 0,
  "previous_cursor_str": "0",
  "next_cursor": 1333504313713126852,
  "users": [
        {
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar"
         },
         {
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar"
         },
         {
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar",
          "foo": "bar"
         }
     ],
     "next_cursor_str": "1333504313713126852"
}

我需要将所有数据合并到一个包含每个用户信息的列表中。问题是当我这样做时,我得到了这个结构:

friends_list = [friends_list, raw_friends_list['users']]

[
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
]
[
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
]    

代替:

[
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
    {"foo": "bar","foo": "bar"}
]  

有谁知道用python实现这一目标的正确方法?

问候,

4

1 回答 1

0
friends_list.extend(raw_friends_list['users'])
于 2013-04-26T11:43:04.063 回答