Python 仅获取在特定索引处具有最低值的子列表
我有一张单子Python 仅获取在特定索引处具有最低值的子列表,python,list,max,min,nested-lists,Python,List,Max,Min,Nested Lists,我有一张单子 [[1, 2, 48.5], [1, 3, 66.7], [1, 4, 32.4]] 我只想得到一个索引为2的最小值的列表,所以我只得到这样一个列表 [1, 4, 32.4] [1, 4, 32.4] 我尝试过使用min()和max()函数,但我想不出任何东西,您可以使用并在键中指定要根据第二个索引排序的内容: from operator import itemgetter l = [[1, 2, 48.5], [1, 3, 66.7], [1, 4, 32.4]] min(
[[1, 2, 48.5], [1, 3, 66.7], [1, 4, 32.4]]
我只想得到一个索引为2的最小值的列表,所以我只得到这样一个列表
[1, 4, 32.4]
[1, 4, 32.4]
我尝试过使用min()和max()函数,但我想不出任何东西,您可以使用并在键中指定要根据第二个索引排序的内容:
from operator import itemgetter
l = [[1, 2, 48.5], [1, 3, 66.7], [1, 4, 32.4]]
min(l, key=itemgetter(2))
输出