Also known as a hash table
Common dictionary built-in methods
Dict.clear ()
Dict.fromkeys ()
# Create a new dictionary with the key of the dictionary in sequence seq, Val for the dictionary all keys corresponding to the initial value >>> list =[1,2,3]>>> dict = Dict.fromkeys (list)>>> dict{1:none, 2:none, 3: None}>>> dict = Dict.fromkeys (list,1)>>> dict{1:1, 2:1, 3:1}
Dict.get (Key, Default=none) # Returns the value of the specified key if the value does not return the default value in the dictionary
Dict.has_key (key) # returns False if the key returns true in the dictionary dict
Dict.items () # Returns an array of traversed (key, value) tuples in a list
Dict.keys () # Returns a dictionary of all keys in a list
Dict.values () # returns all values in the dictionary as a list
Dict.setdefault (Key, Default=none) # is similar to get (), but if the key does not already exist in the dictionary, the key will be added and the value will be set to default
Dict.update ()
# update the key/value pairs of the dictionary dict2 to dict >>> Dict1 = {1:'a'}>>> dict2 = { 2:'b'}>>> dict1.update (dict2)>>> dict1{ 'a'b'}
python--Dictionary