Python 匿名函数

匿名函数

 1 def calc(n):
 2     return n**n
 3 
 4 
 5 print(calc())
 6 
 7 
 8 # 换成匿名函数
 9 calc = lambda n:n**n
10 print(calc(n))
11 
12 
13 # 匿名函数主要是搭配其它函数使用
14 res = wap(lambda x:x**2,[1,5,7,4,8])
15 for i in res:
16     print(i)
原文地址:https://www.cnblogs.com/cheese320/p/8893056.html