<分区> 分区>
Possible Duplicate:
In Python, what is the difference between “.append()” and “+= []”?
在 Python 中,我最近注意到您可以通过两种方式附加列表项:
a.append(1)
a += [1]
我喜欢使用第二种方法,因为它对我来说更具可读性。使用它有什么缺点吗?
<分区> 分区>
Possible Duplicate:
In Python, what is the difference between “.append()” and “+= []”?
在 Python 中,我最近注意到您可以通过两种方式附加列表项:
a.append(1)
a += [1]
我喜欢使用第二种方法,因为它对我来说更具可读性。使用它有什么缺点吗?