First, List
A set of ordered items. variable data type "can be added and censored"
A list is a collection of data surrounded by square brackets "[]", with different members separated by ",".
The list can contain any data type, or it can contain another list
Lists can access members by ordinal
Common list operations:
List.append () Append member, member data
List.pop () Delete Members, delete member I
List.count (x) calculates the number of occurrences of the parameter X in the list
List.remove () Remove members from list, delete members directly I
List.extend (l) Append another list to the list L
List.reverse () Reverses the order of the members in the list
List.index (x) Gets the position of the parameter X in the list
List.sort () sort the members in the list
List.insert () inserting data into the list insert (A, B) inserts data into the list
Two, the meta-group
Immutable Sequences
A tuple is a collection of data surrounded by parentheses "()", with different members separated by ","
Unlike lists: the data in a tuple cannot be changed once it is established
Access by subscript
Statement:
L= (a)
Tuples with 0 elements: L = ()
Tuples with 1 elements: l= (1,) note a comma
Third, the dictionary
A collection of key-value pairs (map)
A dictionary is a collection of data surrounded by curly braces "{}"
Differences from lists: Dictionaries are unordered , and members are accessed through keys in the dictionary.
The dictionary is mutable and can contain any other type
Statement:
M={K1:V1,K2:V2}
Access M[K1] will get V1
Common Dictionary operations:
Dic.clear () Empty dictionary
Dic.keys () Get a list of keys
Dic.values () Get a list of values
Dic.copy () Copy Dictionary
Dic.pop (k) Delete key k
Dic.get (k) Gets the value of the key K
Dic.update () Update member, if member does not exist, equivalent to join
Dic.items () Gets a list of keys and values
Dic.popitem
Python list tuple dictionary