python中append函数怎么用

lewis 2019-04-08 20次阅读

在python中使用append函数的方法

append:append()函数的作用是用于在列表末尾添加新的对象。

append()函数语法:

list.append(obj)

参数:

obj:添加到列表末尾的对象。

append()函数使用方法:

aList = [123, 'xyz', 'zara', 'abc'];

aList.append( 2009 );

print "Updated List : ", aList;

输出结果为:

Updated List : [123, 'xyz', 'zara', 'abc', 2009]



发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。