Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/318.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 仅获取在特定索引处具有最低值的子列表_Python_List_Max_Min_Nested Lists - Fatal编程技术网

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))
输出