# lambda关键字 x:形参 x+10:返回值
fun = lambda x: x + 10
print(fun(10))
name = 'awqa'
def change_name(x):
return x + '_sb'
print(change_name('zst'))
def foo(n):
print(n)
def bar(name):
print('my name is %s' % name)
foo(bar)
# 这样调用会报错,参数那么必须要传值才可以,因为打印的时候,引用了这个变量
# foo(bar())
foo(bar('sen'))
# 返回值也可以是函数
def handle():
print('from handle')
return handle
handle()()
def test1():
print('from test1')
def test2():
print('from test2')
# test1这个方法执行不完,return 就不返回,就一直等待
return test1()
test2()
Python学习笔记------隐式函数与高阶函数
猜你喜欢
转载自blog.csdn.net/weixin_39180334/article/details/81068068
今日推荐
周排行