Python append()方法--list

描述

  • append()方法:用於向列表末尾添加新的對象

語法

  • 語法格式:list.append(object)

參數

  • object:添加到列表末尾的對象,這裏的對象能夠是一個元素、列表、字典或元組等。

返回值

  • 無返回值

實例

實例:html

#!/usr/bin/python3

a = ['abc', '2019_11', 'pople']
bac = ['aYuYa']
others = {'name': 'jack'}
tuples = ('yxs', 100)

a.append('python')
a.append(bac)
a.append(tuples)
a.append(others)
print("New list: " + str(a))

輸出:python

New list: ['abc', '2019_11', 'pople', 'python', ['aYuYa'], ('yxs', 100), {'name': 'jack'}]
相關文章
相關標籤/搜索