匿名函数
匿名函数
# 函数名 = lambde 参数:返回值
#参数可有多个,逗号分开
1 def cale(n): 2 return n*n 3 print(cale(3)) 4 5 cale = lambda n:n*n 6 print(cale(5))
dic={'k1':10,'k2':100,'k3':30}
print(max(dic))
print(max(dic,key=lambda k:dic[k]))
def fun(key):
return dic[key]
print(max(dic,key=fun))