7.3 函数作为参数传递
一、函数做为参数传递
这是一种计算逻辑的传递,而非数据的传递
案例:
def test_func(compute): result = compute(1, 2) return result def compute_func(x, y): return x + y print(test_func(compute_func))输出结果:
3
Last updated
Was this helpful?
这是一种计算逻辑的传递,而非数据的传递
案例:
def test_func(compute):
result = compute(1, 2)
return result
def compute_func(x, y):
return x + y
print(test_func(compute_func))
输出结果:
3
Last updated
Was this helpful?
Was this helpful?