Python函数lambda表达式

fn1 = lambda : print('hello world')
print(fn1())

fn2 = lambda a, b : a if a>b else b
print(fn2(10, 20))

fn3 = lambda a, b , c = 10: a + b + c
print(fn3(10, 20))

fn4 = lambda *arg : arg
print(fn4(1, 2, 3, 4, 5))

fn5 = lambda **kwargs:kwargs
print(fn5(name='gzy'))

posted @ 2021-03-08 19:24  code-G  阅读(92)  评论(0编辑  收藏  举报