Python basics _ type_dict, python basics _ dict
# The dict dictionary is not as suitable as the key-value dictionary. I don't know how this name came from. It can be used for usernames and passwords, but isn't it too low to use this database?
# Expand with braces {} and separate each element with commas (,). Each element must have key and value, and key and value are separated by colons.
A = {'A': 1, 'B': 2} # 'A', 'B' is key, 1, 2 is value
A. get ('A') # obtain the value corresponding to the key. The result is 1.
A. keys () # obtain all the keys in the dictionary. The result is ['A', 'B'], a list, and intelligence! More intimate!
A. pop ('A') # delete a key element and 1 is displayed. The result is {'B': 2}
B = {'C': 3}
A. update (B) # add another dictionary. The result is {'C': 3, 'B': 2}
A. values () # return all values. The result is [3, 2], a list. It's so intelligent !!! I'm coming again...
A ['B'] # obtain the value corresponding to the key like get. What should we do with get? Well, I don't understand it. I can't understand the good habits of foreigners, it may also have different functions. Please be advised if you know it.
A [1] # the error message does not contain the key 1, so .... Dict cannot be sliced