匿名函数:python2和python3的区别

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了匿名函数: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) 


技术分享

技术分享




以上是关于匿名函数:python2和python3的区别的主要内容,如果未能解决你的问题,请参考以下文章

python2和python3的输入和输出区别

python2和python3的区别

Python2和Python3的区别(未完待续。。。。)

python3和Python2的区别

python3中的 zip()函数 和python2中的 zip()函数 的区别

Python2 和 Python3 区别汇总