def add(x,y): return x+yadd = lambda x,y:x+yprint(add(1,2))dic={'k1':10,'k2':100,'k3':30}def func(key): return dic[key]print(max(dic,key=func)) #根据返回值判断最大值,返回值最大的那个参数是结果print(max(dic,key=lambda key:dic[key]))max([1,2,3,4,5,-6,-7],key=abs)ret = map(abs,[-1,2,-3,4])for i in ret: print(i)def func(x): return x**2ret = map(func,[-1,2,-3,4])for i in ret: print(i)ret = map(lambda x:x**2,[-1,2,-3,4])
来源:https://www.cnblogs.com/CoolClare/p/10938124.html