from functools import partial
def foo(x, y, z):
return x + y + z
# 在执行偏函数时,将参数传入原函数中执行,将结果返回给偏函数,
new_foo = partial(foo, z=4)
print('new_foo: ', new_foo)
print('new_foo(): ', new_foo(3, 4))
# 输出:
new_foo: functools.partial(<function foo at 0x0000021C02413F40>, z=4)
new_foo(): 11
标签:partial,函数,functools,理解,简单,print,new,foo
From: https://www.cnblogs.com/f-carey/p/17245152.html