我希望将一个函数的输出设置为另一个函数的输入,如下所示
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()缺少两个必需的位置参数:'b‘和'c’
你能告诉我怎么改变我的代码吗?
发布于 2015-01-24 16:49:00
只需使用星号:
pro(*math(a,b))发布于 2015-01-24 16:49:23
可以将返回的值解压缩为参数:
args = math(3, 4) # returns (a, b, c)
print pro(*args) # pro(a, b, c)https://stackoverflow.com/questions/28127811
复制相似问题