Python list operation summary

list common operations

name_list:
name_list.append   
name_list.count    
name_list.insert   
name_list.reverse
name_list.clear    
name_list.extend   
name_list.pop      
name_list.sort
name_list.copy     
name_list.index    
name_list.remove 
Serial number classification Keywords / functions / methods Explanation
1 increase List.insert (index, data) Insert data at the specified position
List.append (data) Append data at the end
List.extend (list 2) Append the data of list 2 to the list
2 modify List [index] = data Modify the data of the specified index
3 delete del list [index] Delete the specified index data
List.remove [data] Delete the first specified data
List.pop Delete the last data
List.pop (index) Delete the specified index data
List.clear clear the list
4 statistics len (list) List length
List.count (data) The number of times the data appears in the list
5 Sort List.sort () Ascending order
List.sort (reverse = True) Sort descending
List.reverse () Reverse order, reverse
Published 108 original articles · praised 48 · 50,000+ views

Guess you like

Origin blog.csdn.net/larry1648637120/article/details/98197512