<分区>
我有以下中断的代码:
l = []
tup = ('a', 'b')
l = l + tup
给出以下错误
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate list (not "tuple") to list
但是下面的代码运行
l = []
tup = ('a','b')
l += tup
没有任何错误。
我一直以为l+=和l = l +是一样的
这里发生了什么?