Python3 list.remove()方法

參數
  • obj -- 這是要從列表中刪除的對象。

返回值

此方法不返回任何值,只是從列表中刪除指定的對象。

示例

下麵的示例顯示 remove()方法的使用。
#!/usr/bin/python3

list1 = ['physics', 'Biology', 'chemistry', 'maths']
list1.remove('Biology')
print ("list now : ", list1)
list1.remove('maths')
print ("list now : ", list1)

當我們運行上面的程式,會產生以下結果 -
list now :  ['physics', 'chemistry', 'maths']
list now :  ['physics', 'chemistry']

上一篇: Python3字串 下一篇: Python3列表