In List of Dicts, find min() value of a common Dict field

后端 未结 5 1759
说谎
说谎 2020-11-27 12:00

I have a list of dictionaries like so:

[{\'price\': 99, \'barcode\': \'2342355\'}, {\'price\': 88, \'barcode\': \'2345566\'}]

I want to fin

5条回答
  •  遥遥无期
    2020-11-27 12:38

    can also use this:

    from operator import itemgetter
    
    lst = [{'price': 99, 'barcode': '2342355'}, {'price': 88, 'barcode': '2345566'}]  
    max(map(itemgetter('price'), lst))
    

提交回复
热议问题