1.lambda
func = lambda x,y:9+x
参数:x,y
函数体:9+x==>>return 9+x
func:函数名
def func(x,y):
return x+9
def f1():
return “F1”
def f2(x):
x()#执行了函数
f1=>函数
f2=>函数
f1()=>执行函数
f2(f1)执行f2,把f1当成参数传递
扩展:函数名可以当做参数传递
函数名()=>执行函数
函数名==》代指函数
def MyFilter(func,arg):
for i in arg:
func(i)
def MyPrint(x):
print(x)
MyFilter(MyPrint,[11,22,33,44,55,6,6])
Connected to pydev debugger (build 172.3317.103)
11
22
33
44
55
6
6
Process finished with exit code 0