python-append()方法

append() 方法向列表的尾部添加一个新的元素。只接受一个参数。

>>> mylist = [1,2,3,4]
>>> mylist
[1, 2, 3, 4]
>>> mylist.append(5)
>>> mylist
[1, 2, 3, 4, 5]
>>> mylist.append('test')
>>> mylist
[1, 2, 3, 4, 5, 'test']
>>> 

 

posted @ 2016-03-07 10:07  北海悟空  阅读(1055)  评论(0编辑  收藏  举报