python中函数名怎么作为参数传递,有谁可以讲清楚吗

在python函数的编写中,经常发现Python中的函数名作为参数传递,真是惊呆我也。python中函数名怎么作为参数传递,有哪位大能可以讲清楚吗

这个不难理解吧?简单写个demo:square和cube分别是求x的平方和立方的函数,test是测试函数,可以接收函数参数。

>>> def square(x):
    return pow(x, 2)

>>> def cube(x):
    return pow(x, 3)

>>> def test(func, x):
    return func(x)

>>> test(square, 5)
25
>>> test(cube, 5)
125