跳至內容
選單
此問題已被標幟
2 回覆
228 瀏覽次數

Hi guys!!!!!

Please i have this result :

[{'project_id': (5, u'toto114'), 'id': 21}]

I want to get the first value in project_id field which means the 5.

Please what can i do!!!!!

print res[project_id'][0]????

Thanks in advance :)

頭像
捨棄
最佳答案

Let's assume,

result = [{'project_id': (5, u'toto114'), 'id': 21}]

If you want to get value "5" then use following syntex,

print result[0]['project_id'][0] 

頭像
捨棄
最佳答案

res[project_id'][0] will print 5

res[project_id'][1] will print toto114 

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
3月 25
1414
0
1月 25
3493
1
8月 23
14851
1
8月 23
13500
1
7月 23
10482