8day
1. Data type: Tuple
Tuples: A collection of ordered, immutable data. However, if you include other mutable elements, these elements are variable. Shown to tell others, here can not be modified;
A = (1,2,3,4,5,[' 1 ', ' a '])
2. Data type: Dictionary
Dictionary: Dictionary is a kind of key-value data type, use like the dictionary that we use to go to school, check the detailed content of the corresponding page by pen stroke, letter;
Characteristics:
-Unordered
-Fast Search speed
-can store any number of values, can be modified, can not be unique
-key-value structure
-key must be hash, must be immutable data type, must be unique
2.1 Basic operation of the dictionary:
2.1.1 Delete
A, pop delete
B, Popitem random deletion
Dict.popitem ()
C, del Delete
Del Dict[key]
D, clear clear
2.1.3 Increase
A. Direct Plus
Dict[key]=value If there is a replacement, if none is added
2.1.4 Modification
2.1.5 Get
Dict.get (key), if any, returns the corresponding value. If none, then return "None"
Dict[key]=value
K in dict determines if there is a key, returns true if any, or false if none
2.2 Common operations:
Dict.keys all key values of the output dictionary
Dict.value all value values of the output dictionary
Dict.items the dictionary into a list
Dict.update (DICT2) merges two dictionaries. If you have the same key, overwrite it. Without the same key, create the
Dict.setdefault (Key,value) If you have this key, return value. If not, create a
Fromkeys converting a list to a dictionary
Python Beginner Eighth Day