代码点读机 / Python / append

append Python · 列表方法

在列表末尾添加一个元素。

怎么用

列表.append(元素)

小例子

a = [1, 2]
a.append(3)
print(a)

运行结果

[1, 2, 3]

官方文档:https://docs.python.org/zh-cn/3/library/stdtypes.html#typesseq-mutable

在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← Python全部词条