描述
Python列表方法append()將傳遞的 obj 附加到現有列表中。
用法
以下是語法append()方法 -
list.append(obj)
參數
obj- 這是要附加到列表中的對象。
返回值
此方法不返回任何值但更新現有列表。
示例
下麵的例子展示了 append() 方法的用法。
#!/usr/bin/python
aList = [123, 'xyz', 'zara', 'abc'];
aList.append( 2009 );
print "Updated List:", aList
當我們運行上麵的程序時,它會產生以下結果 -
Updated List: [123, 'xyz', 'zara', 'abc', 2009]
相關用法
- Python List remove()用法及代碼示例
 - Python List insert()用法及代碼示例
 - Python List clear()用法及代碼示例
 - Python List cmp()用法及代碼示例
 - Python List pop()用法及代碼示例
 - Python List index()用法及代碼示例
 - Python List sort()用法及代碼示例
 - Python List list()用法及代碼示例
 - Python List max()用法及代碼示例
 - Python List count()用法及代碼示例
 - Python List len()用法及代碼示例
 - Python List min()用法及代碼示例
 - Python List reverse()用法及代碼示例
 - Python List copy()用法及代碼示例
 - Python List extend()用法及代碼示例
 - Python Lock acquire()用法及代碼示例
 - Python Lock release()用法及代碼示例
 - Python Lock locked()用法及代碼示例
 - Python numpy.less()用法及代碼示例
 - Python Sympy Permutation.list()用法及代碼示例
 
注:本文由純淨天空篩選整理自 Python List append() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
