小编Pra*_*ter的帖子

如何在Python中调用作为参数传递的函数

是否可以调用在 Python 中作为参数传递的函数?我试过这样做,但它给出了错误

代码:

def doStuff():
    print("doing stuff")

def doWork():
    print("doing work")

def call_function(func):
    func()

call_function(doStuff())
call_function(doWork())
Run Code Online (Sandbox Code Playgroud)

错误:

TypeError: 'NoneType' object is not callable
Run Code Online (Sandbox Code Playgroud)

python parameter-passing

0
推荐指数
1
解决办法
73
查看次数

标签 统计

parameter-passing ×1

python ×1