How to loop over a list of dicts and print values of a specific key?

前端 未结 1 1241
[愿得一人]
[愿得一人] 2021-01-28 10:02

I\'m new to Python and have (what I know to be a very simple) question.

Running Python 3.4.

I have a list that I need to iterate over and pull specific informati

相关标签:
1条回答
  • 2021-01-28 10:53

    If I understood you correctly. You are looking for fetching a value using key from a dict.

    Ex:

    for i in parts:
        print(i["id"])   #or print(i.get("id"))
    

    Output:

    phwl
    a06c5
    

    MoreInfo in Python Dictionaries

    0 讨论(0)
提交回复
热议问题