【发布时间】:2017-01-30 11:14:59
【问题描述】:
这是我的功能
def f(*a,b):
print (sum(a) , b)
以下调用导致错误
f([x for x in range(100)] , b=0)
Traceback (most recent call last):
File "<pyshell#61>", line 1, in <module>
f([x for x in range(100)] , b=0)
File "<pyshell#59>", line 2, in f
print (sum(a) , b)
TypeError: unsupported operand type(s) for +: 'int' and 'list'
当我不使用 sum(a) 而只使用 a 时,这工作正常,请告诉我这是怎么回事。
【问题讨论】:
标签: python-3.x arguments args packing