高阶函数:将函数作为参数传入
#!/usr/bin/python
def cal(x, y, func):
return func(x) + func(y);
print cal(-1, -3, abs);
高阶函数:将函数作为参数传入
#!/usr/bin/python
def cal(x, y, func):
return func(x) + func(y);
print cal(-1, -3, abs);
事半功倍的高阶函数,分分钟提高你的编程技术
高阶函数这里使用的是python3.6版本高阶函数:就是把函数当成参数传递的一种函数;示例:def add(x,y,function): return function( x)+ function( y) print (add(-3,5,abs)) 注解:1.调用add函数,分别执行abs(-3)和abs(5),分别计算出他们的值2.最后在做和运算,最终结果输出是8&n
举报文章
请选择举报类型
补充说明
0/200
上传截图
格式支持JPEG/PNG/JPG,图片不超过1.9M