Getting a list of specific index items from a list of dictionaries in python (list comprehension)

后端 未结 5 1130
北海茫月
北海茫月 2021-01-24 08:31

I have a list of dictionaries like so:

listDict = [{\'id\':1,\'other\':2},{\'id\':3,\'other\':4},{\'id\':5,\'other\':6}]

I want a list of all t

5条回答
  •  感情败类
    2021-01-24 08:51

    For the python geeks:

    import operator
    map(operator.itemgetter('id'), listDict)
    

提交回复
热议问题