函数在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
更新于: