说说例子吧,一般会在sorted, max, 这类函数里的key用lambda. 比如有一个比较复杂的数组结构,s = [('a', 3), ('b', 2), ('c', 1)] 对这个数组用第二个元素排序。可以写成 sorted(s, key=lambda x:x[1])