2016-06-21 157 views
-3

以下是我的代碼。我想在python中遍歷這個數組,並且想要獲取json對象的鍵和值。 json數組在另一個文件中。我已經在一個變量中檢索了整個數組。如何通過鍵循環

[{'EJCx5IK2l': 'https://www.linkedin.com/in/pub/shane-coineandubh/9/22b/231'}, 
{'EJDtW9tnl': 'https://www.linkedin.com/in/in/riccardo-ermini-75790b11'}, 
{'EJDwgrFhg': 'https://www.linkedin.com/in/pub/guenter-sanwald/7/941/b72'}] 
+2

的重複http://stackoverflow.com/q/7409078/4700944 –

回答

0

對於JSON數組稱爲myJson:

for d in myJson: #for each dictionary in list 
    for e in d: #for each key in dictionary 
     print('key is', e) 
     print('value is', d[e])