0 python sum list
观察[1, 2] + [3, 4]结果[1, 2, 3, 4],我推断sum([[1, 2], [3, 4]])应该这样做,但我得到了这个错误:
[1, 2] + [3, 4]
[1, 2, 3, 4]
sum([[1, 2], [3, 4]])
TypeError: unsupported operand type(s) for +: 'int' and 'list'
有人可以解释一下吗?我知道我可以使用itertools.chain,但为什么这不起作用?
itertools.chain
Ign*_*ams 6
start默认为0.
资源
sum(..., [])
归档时间:
12 年,7 月 前
查看次数:
108 次
最近记录: