函数是Python中的特殊地位
# 函数是Python中的特殊地位
# 它们可以作为参数传递给其他函数,也可以作为其他函数的值返回,也可以分配给变量并存储在数据结构中
>>> def myfunc(a, b):
... return a + b
...
>>> funcs = [myfunc]
>>> funcs[0]
<function myfunc at 0x107012230>
>>> funcs[0](2, 3)
5
# 函数是Python中的特殊地位
# 它们可以作为参数传递给其他函数,也可以作为其他函数的值返回,也可以分配给变量并存储在数据结构中
>>> def myfunc(a, b):
... return a + b
...
>>> funcs = [myfunc]
>>> funcs[0]
<function myfunc at 0x107012230>
>>> funcs[0](2, 3)
5