Latest web development tutorials

Python3 List remove()方法

Python3 列表 Python3列表


描述

remove() 函數用於移除列表中某個值的第一個匹配項。

語法

remove()方法語法:

list.remove(obj)

參數

  • obj -- 列表中要移除的對象。

返回值

該方法沒有返回值但是會移除兩種中的某個值的第一個匹配項。

實例

以下實例展示了remove()函數的使用方法:

#!/usr/bin/python3

list1 = ['Google', 'w3big', 'Taobao', 'Baidu']
list1.remove('Taobao')
print ("列表现在为 : ", list1)
list1.remove('Baidu')
print ("列表现在为 : ", list1)

以上實例輸出結果如下:

列表现在为 :  ['Google', 'w3big', 'Baidu']
列表现在为 :  ['Google', 'w3big']

Python3 列表 Python3列表