Skip to main content
 首页 » 编程设计

Python 列表追加

2025年05月04日14EasonJim

<分区>

Possible Duplicate:
In Python, what is the difference between “.append()” and “+= []”?

在 Python 中,我最近注意到您可以通过两种方式附加列表项:

a.append(1) 
a += [1] 

我喜欢使用第二种方法,因为它对我来说更具可读性。使用它有什么缺点吗?