匿名函数:python2和python3的区别

 1 #coding=utf-8
 2 
 3 def test(a,b,func):
 4     result = func(a,b)
 5     return result
 6 #python2中的方式
 7 #func_new = input("请输入一个匿名函数:")
 8 
 9 #python3中的方式
10 func_new = input("请输入一个匿名函数:")
11 func_new = eval(func_new)
12 
13 num = test(11,22,func_new)
14 print(num) 



结果

每天学习新的知识,会让自己更加充实
原文地址:https://www.cnblogs.com/fengpiaoluoye/p/7616850.html