我想使函数返回可变数量的输出。
我尝试过out1, out2 = function()[:-1]
,out1, out2 = function()[:2]
和使用function()
语句更改if
def function():
a=1;b=2;c=3
return a,b,c
out1, out2 = function() ### Line number 4
我只想通过更改function()
而不使用if
语句来执行“第4行”。out1, out2 = function()
当然,这表明ValueError: too many values to unpack (expected 2)
out1, out2 = function()
执行此操作:
values = function() print "I've got", len(values), "return values"