Python 基礎教程
append() 方法用于在列表末尾添加新的對象。
append()方法語法:
list.append(obj)
該方法無返回值,但是會修改原來的列表。
以下實例展示了 append()函數(shù)的使用方法:
#!/usr/bin/python aList = [123, 'xyz', 'zara', 'abc']; aList.append( 2009 ); print "Updated List : ", aList;
以上實例輸出結(jié)果如下:
Updated List : [123, 'xyz', 'zara', 'abc', 2009]其他擴展