1007 Python之List中remove,pop,del區別分析

Python之List中remove,pop,del區別分析 代碼塊 remove #remove刪除首個符合條件的元素,並不刪除特定的索引。 **n =[1,2,2,3,4,5] n.remove(3) print (n)** #輸出 [1, 2, 2, 4, 5] pop #pop按照索引刪除字符,返回值能夠付給其餘的變量,返回的是你彈出的那個數值。 n =[1,2,2,3,4,5] a=n
相關文章
相關標籤/搜索