Python函数输入

Python function input

我想将一个函数的输出设置为另一个函数的输入, 像这样

def math(a,b):
some code...
return(a,b,c)

def pro(a,b,c):
some code
return(e)
#and then call function by:
pro(math(a,b))

然而,

TypeError: pro() missing 2 required positional arguments: 'b' and 'c'

你能告诉我如何更改我的密码吗?

只需使用星号:

pro(*math(a,b))

您可以解压返回值作为参数:

args = math(3, 4) # returns (a, b, c)
print pro(*args) # pro(a, b, c)