First, List
1. List Script operator: Table
(1) Amplified operator:
"+": Used for combination lists; [1,2,3]+[4,5,6]==>[1,2,3,4,5,6]
"*": repeat; [2,3]*2==>[2,3,2,3]
2. List function
CMP (LIST1,LIST2): Compares elements of two lists, returns 1 when List1<list2, returns 1 when List1>list2, and returns 0 when List1=list2;
Len (list): Returns the number of list elements;
Max: Returns the maximum value of the list element;
Min (list): Returns the minimum value of the list element;
3. List method
(1) Amplification Method:
List.append (obj.): Adds a new object at the end of the list;
List.extend (seq): Appends all the elements of a list and tuple to the end of the list by appending multiple values of another sequence at one time (1, SEQ as list and tuple), and 2, when SEQ is a dictionary, adds all keys to the dictionary;)
List.insert (index,obj): Adds the object to the corresponding index position;
(2) Delete element:
List.pop ([obj=list[-1]): The last element in the list is deleted by default, and the value of the element is returned, List.pop (1) deletes the second-lowest element in the list;
List.remove (obj): Deletes the first occurrence of a value in the list;
(3) Number of statistics elements appearing in list: List.count (obj)
(4) Reverse list element: List.reverse ()
(5) Sort the original list: List.sort ([func])
4. The value of the access list:
List[index]: Access the index points to the value, starting from 0;
LIST[-1]: Access the last element of the countdown;
List[1:3]: Accesses the 2nd element to the 3rd element, the element with index 3 is not accessible;
List[1:]: Access the 2nd element to the last element.
5. Other:
Delete element statement: Del List[index]
Update element value: list[1]=3; ===> directly changes the value of the element indexed to 1 to "3"
Determine if an element value exists: 3 in [1,2,3]==> returns True
Python Data Structure Summary