flask的partial偏函数
flask的partial偏函数
# 偏函数partial 它的作用是可以存储参数
from functools import partial
def func(a,b,c,d):
return a+b+c+d
# 第一个参数是函数的对象,第二个以及后面的参数都是函数的参数,这里严格按照python的传传参规则
res = partial(func, 1)
print(res) # functools.partial(<function func at 0x000001E763099EE8>, 1)
print(res(2,3,4)) # 结果10
Only you can control your future
You're not alone. You still have family,peopel who care for you and want to save you.