Python dictionary Functions
Method Name operation dict. cleara () deletes all the elements in the dictionary. copya () returns a copy of the Dictionary (Shortest copy) dict. fromkeysc (seq, val = None) c creates and returns a new dictionary, which uses the elements in seq as the dictionary key, val is the initial value corresponding to all keys in the dictionary (if this value is not provided, the default value is None) dict. get (key, default = None) a pairs the key in the dictionary dict and returns its corresponding value. If this key does not exist in the dictionary, the default value is returned. (Note, the default value is None.) dict. has_key (key) if the key exists in the dictionary, True is returned; otherwise, False is returned. after the in and not in methods are introduced in Python2.2, this method is almost obsolete, but a working interface is still provided. Dict. items () returns a list of tuples containing Dictionary (key, value) pairs (dict. keys () returns a list of dict that contains the dictionary's middle keys. iter () d Method iteritems (), iterkeys (), itervalues () are the same as their non-iterative methods. The difference is that they return an iterator instead of a list. Dict. popc (key [, default]) c is similar to the get () method. If the key in the dictionary exists, delete it and return the dict [key]. If the key does not exist, the default value is not provided, causing a KeyError. Dict. setdefault (key, default = None) e is similar to the method set (). If the key does not exist in the dictionary, dict [key] = default assigns a value to it. Dict. update (dict2) a adds the dictionary dict2 key-value pairs to the dictionary dictdict. values () and returns a list containing all the values in the dictionary.