【发布时间】:2020-05-16 23:38:40
【问题描述】:
我有以下两个字典列表:
regionA = [dict(is_buy_order=True, price=1000, type=1),
dict(is_buy_order=True, price=100, type=2),
dict(is_buy_order=False, price=10, type=2)]
regionB = [dict(is_buy_order=False, price=10, type=1),
dict(is_buy_order=True, price=100, type=1),
dict(is_buy_order=True, price=1000, type=2)]
考虑到来自 regionA 和 regionB 的数据,我想返回类型 1 和类型 2 的键 'price' 中具有最高值和键 'is_buy_order' 中的值 'True' 的字典.
我见过一些例子(例如Return the dictionary from a list of dictionaries with the highest value in a specific key)适用于单个字典列表,但不能使它们与集合一起使用,我想知道是否有直接的方法。
(这里的第一个问题:如果需要澄清,请告诉我,感谢您的帮助!)
【问题讨论】:
标签: python dictionary