If you want to save one by one of the corresponding type of data, you can use Dict to indicate that all the data in the Dict are key-value pairs.
First, create dict (Create Dict with {})
Features of Dict:
(1) The elements in the dict are all key-valued pairs.
(2) Dict is disordered.
(3) Dict search efficiency is very high.
(3) The dict is found by the key value, so the key value cannot be duplicated or variable.
Ii. accessing elements in the Dict
(1) access by d[]
The IF statement is added here to determine whether the key value exists or not, to avoid the program error.
(2) through the D.get () method to access
When accessed through the Get () method, returns the value directly if the key value exists, or none if the key value does not exist.
Third, update the elements in the Dict
The element in the dict is updated directly by d[], and if key exists, the value is updated, and if the key value does not exist, the element is appended in Dict.
Iv. traversing elements in Dict: The key value in Dict can be traversed through a for loop
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
The dict in Python