lambda 对字典的某个最大值取值

-- coding: utf-8 --

d = {'Reference(m)': (-7.22222222222222, 57.222222222222214),
'Vendor': (38.20370370370372, 11.796296296296289),
'Title': (0, 50), 'VendorDesc': (37.000000000000014, 12.999999999999991),
'Detail': (42.296296296296305, 57.703703703703695), 'Qty': (100.00000000000037, -12.999999999999991),
'P/N': (-12.999999999999991, 62.999999999999986), 'Item': (12.999999999999991, 37.000000000000014),
'Mfr': (46.62962962962963, 3.370370370370371), 'Mfr P/N': (-12.03703703703703, 99.03703703703738),
'Type': (37.000000000000014, 12.999999999999991), 'Vendor P/N': (-12.27777777777777, 62.277777777777764)}

q_max = min(d, key=lambda x: d[x][0])
m_max = max(d, key=lambda x: d[x][1])
print(sum([2, 18, 9, 22, 17, 24, 8, 12, 27]))
print(q_max)
print(m_max)

posted @ 2020-08-28 18:24  ty1539  阅读(628)  评论(0编辑  收藏  举报