这称为currying或部分应用程序。您可以使用内置的functools.partial()。像下面这样的东西会做你想要的。
import functoolsdef add(x,y): return x + yinc2 = functools.partial(add, 2)print inc2(3)

这称为currying或部分应用程序。您可以使用内置的functools.partial()。像下面这样的东西会做你想要的。
import functoolsdef add(x,y): return x + yinc2 = functools.partial(add, 2)print inc2(3)