我是一个试图达到以下目标的蟒蛇新手:
我有一份名单:
lst = [[567,345,234],[253,465,756, 2345],[333,777,111, 555]]
我想映射 lst 到另一个列表中,只包含每个子列表中的第二个最小数。所以结果应该是:
[345, 465, 333]
例如,如果我只对最小的数字感兴趣,我可以这样做:
map(lambda x: min(x),lst)
我希望我能做到这一点:
map(lambda x: sort(x)[1],lst)
但 sort 不链接。(返回 Nothing)
这样的事情也是不允许的:
map(lambda x: sort(x); x[1],lst) #hence the multiple statement question
有没有一种方法可以做到这一点与地图在巨蟒但 而不用定义命名函数?(例如,在 Ruby 中使用匿名块很容易)