我有从 FQL 查询返回的以下内容:
posts_fql = graph.fql({'posts':"SELECT uid, name, pic, username FROM user WHERE is_app_user=1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"})
print ast.literal_eval(json.dumps(posts_fql))
[
{
'fql_result_set': [
{
'username': 'sahithi.akasapu',
'pic': 'http://profile.ak.fbcdn.net/hprofile-ak-ash3/173521_1033451070_925702476_s.jpg',
'uid': 1033451070,
'name': 'Sahithi Akasapu'
},
{
'username': 'joe.kaster.73',
'pic': 'http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yh/r/C5yt7Cqf3zU.jpg',
'uid': 100004855536430,
'name': 'Joe Kaster'
}
],
'name': 'posts'
}
]
我正在尝试使用以下方法在 python 中创建一个列表:
user_list= []
for user in posts_fql:
uid = user['fql_result_set'][0]['uid']
username = user['fql_result_set'][0]['username']
name = user['fql_result_set'][0]['name']
pic = user['fql_result_set'][0]['pic']
user_list.append([uid, username, name, pic])
当我打印 user_list 时,只打印第一组数据(用于用户“测试”)。我怎样才能解决这个问题?