掃二維碼與項目經(jīng)理溝通
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
python 中的append()函數(shù)有助于將給定的項目添加到現(xiàn)有列表的末尾。

讓客戶滿意是我們工作的目標,不斷超越客戶的期望值來自于我們對這個行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價值的長期合作伙伴,公司提供的服務(wù)項目有:域名申請、虛擬空間、營銷軟件、網(wǎng)站建設(shè)、岱岳網(wǎng)站維護、網(wǎng)站推廣。
**list.append(item)** #where item can be numbers, strings, dictionaries etc
append()函數(shù)接受一個參數(shù)。
| 參數(shù) | 描述 | 必需/可選 |
|---|---|---|
| 項目 | 要添加到列表末尾的項目 | 需要 |
這個方法不返回任何值,這意味著它不返回任何值。實際上,這個方法更新了現(xiàn)有的列表。
append()方法的示例append()在 python 中是如何工作的? # flowers list
flowers = ['Rose', 'Lotus', 'Jasmine']
# 'Sunflower' is appended to the flowers list
flowers.append('Sunflower')
# Updated flowers list
print('Updated flowers list: ', flowers )
輸出:
Updated flowers list: ['Rose', 'Lotus', 'Jasmine', 'Sunflower'] append()向列表中添加列表 # flowers list
flowers = ['Rose', 'Lotus', 'Jasmine']
# flowers list
flowers = ['Rose', 'Lotus', 'Jasmine']
# list of vegetables
vegetables = ['Tomato', 'Potato']
# appending vegetables list to the flowers list
flowers.append(vegetables)
print('Updated list: ', flowers)
輸出:
Updated list: ['Rose', 'Lotus', 'Jasmine', ['Tomato', 'Potato']] 
我們在微信上24小時期待你的聲音
解答本文疑問/技術(shù)咨詢/運營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流