#####匿名函数 # def add(a,b): # return a+b # print(add(1,2)) # add = lambda a,b: a+b # print(add(1,2)) # def func(key): # return dic[key] # dic = {'k1':10,'k2':100,'k3':30} # print(max(dic,key=lambda k:dic[k])) # print(min(dic,key=lambda k:dic[k])) # min max filter map sorted ------都可以和lambda配合 ((('a'),('b')),(('c'),('d'))) # ret = zip((('a'),('b')),(('c'),('d'))) # def func(tup): # return {tup[0]:tup[1]} # res = map(func,ret) # print(list(res)) # ret = zip((('a'),('b')),(('c'),('d'))) # res = map(lambda tu:{tu[0]:tu[1]},ret) # print(list(res)) # res = list(map(lambda tu:{tu[0]:tu[1]},zip((('a'),('b')),(('c'),('d'))))) # print(res)
来源:https://www.cnblogs.com/Mr-Feng/p/10820080.html