#!/usr/bin/env python # -*- conding:utf8 -*- # 匿名函数就是不需要显式的指定函数 # 演示用法 name = 'newmet' def change_name(): return name+"_ss" print(change_name()) f = lambda x:x+'_ss' print(f(name)) # 正式用法 ######匿名函数主要是和其它函数搭配使用的###### # lambda x:x+1 l = [3, 24, 100, 88, 213, 1222, 321] print(max(l)) dic = {'k1': 2222, 'k2': 200, 'k3': 20} print(max(dic)) print(dic[max(dic, key=lambda k: dic[k])]) res = map(lambda x: x ** 2, [1, 5, 7, 4, 8]) for i in res: print(i)