是否可以调用在 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)