lambda应用
def test(a, b, func):result = func(a, b)print(result)test(10, 15, lambda x, y: x + y)
?
#coding=utf-8 #python2需要加上coding=utf-8def test(a, b, func):result = func(a, b)return result #python2中的方式 #func_new = input("請輸入一個(gè)匿名函數(shù):")#python3中的方式 func_new = input("請輸入一個(gè)匿名函數(shù):") func_new = eval(func_new)num = test(11, 22, func_new) print(num)結(jié)果: 請輸入一個(gè)匿名函數(shù):lambda x, y: x - y -11?
轉(zhuǎn)載于:https://www.cnblogs.com/xhcdream/p/8159336.html
總結(jié)
- 上一篇: hibernate中*.hbm.xml配
- 下一篇: 如何使用ffmpeg下载腾讯课堂视频(亲