# 这段代码 def calc(n): return n**n print(calc(10)) # 改为匿名函数 calc = lambda n:n**n print(calc(10)) # 格式: 函数名 = lambda 参数:返回值 dic = {'k1':10,'k2':100,'k3':30} print(max(dic,key=lambda k:dic[k])) # 1、现有两元组(('a'),('b')),(('c'),('d')), 请使用python中匿名函数生成列表[{'a':'c'},{'b':'d'}] ret = zip((('a'),('b')),(('c'),('d'))) # def func(tup): # return {tup[0]:tup[1]} res = map(lambda tup:{tup[0]:tup[1]},ret) print(list(res)) #2、 # def multipliers(): # return [lambda x:i*x for i in range(4)] # print([m(2) for m in multipliers()])