Python 装饰器
def fun(a,b):
def ff(x):
print(a,b)
return a*x*x+b*x
return ff
f1 = fun(1,1)
#此时的f1指向的是ff函数 所以执行f1时 就相当于执行的是ff函数所以调用f1函数时需要传递一个参数
print(f1)
print(f1(3))
f2=fun(2,3)
print(f2)
print(f2(3))
会出现什么结果?
<function fun.<locals>.ff at 0x0000020D1D98B9D8>
1 1
12
<function fun.<locals>.ff at 0x0000020D1D513E18>
2 3
27






赞









