相关疑难解决方法(0)

Python函数作为函数参数?

Python函数可以作为另一个函数的参数吗?

说:

def myfunc(anotherfunc, extraArgs):
    # run anotherfunc and also pass the values from extraArgs to it
    pass
Run Code Online (Sandbox Code Playgroud)

所以这基本上是两个问题:

  1. 它是否允许?
  2. 如果是,如何在其他功能中使用该功能?我需要使用exec(),eval()或类似的东西吗?永远不需要弄乱它们.

BTW,extraArgs是anotherfunc参数的列表/元组.

python arguments function

103
推荐指数
4
解决办法
18万
查看次数

标签 统计

arguments ×1

function ×1

python ×1