Dictionary
1. Overview : using a key - the value (key-value) is stored, having a fast search speed (a dictionary may store a plurality of keys - value pairs)
Note : the dictionary are unordered
characteristic key of:
(1) dictionary the key must be unique
(2) key must not be changed in the object
(3) string, integer, etc. are immutable, can be used as the key
(. 4) List is variable, not as the key
Example: holding a plurality of student name and grade
method: use the dictionary, the student's name as a key (assuming no duplicate student name), as the value of student performance
dict1 = { "Tom": 80, "Lilei": 90}
2. access element
acquisition: name dictionary [key]
Add:
delete:
traversal:
3. list and compare
(1) the dictionary to find and insert fast, it will not increase the key-value and slow
(2) Dictionary would take a lot of memory, memory waste multi
list of disadvantages
(1) to find and insert with the increase would reduce the amount of data
(2) small footprint, less memory is wasted
python learning Notes twelve (dictionary)
Guess you like
Origin blog.csdn.net/weixin_38324954/article/details/94619027
Ranking