Method name Operation
Dict.cleara () Delete all the elements in the dictionary
Dict.copya () Returns a copy of the dictionary (shallow copy)
DICT.FROMKEYSC (SEQ,
Val=none) C creates and returns a new dictionary, with the element in SEQ doing the dictionary key, Val making the word
The initial value for all keys in the code (default is None if this value is not provided)
Dict.get (Key,
Default=none) A pair of key keys in the dictionary dict, returns its corresponding value if the dictionary does not exist in the
Key, the value of default is returned (note that the default value of the parameter is None)
Dict.has_key (Key) returns True if the key (key) exists in the dictionary, otherwise false is returned. In Python2.2
After the version introduces in and not, this method is almost obsolete, but it still provides a
The interface that can work.
Dict.items () Returns a list containing the tuple (key, value) in the dictionary
Dict.keys () Returns a list containing the keys in the dictionary
Dict.iter () d method Iteritems (), Iterkeys (), Itervalues () and their corresponding non-iterative methods
, the difference is that they return an iteration instead of a list.
DICT.POPC (Key
[, default]) C and Method get () similar, if the dictionary key key exists, delete and return Dict[key],
Throws a Keyerror exception if the key key does not exist and does not give the default value.
Dict.setdefault (Key,
Default=none) E is similar to method set (), if the key key is not present in the dictionary, the Dict[key]=default is
It is assigned a value.
Dict.update (DICT2) A adds the key-value pairs of the dictionary dict2 to the dictionary dict
Dict.values () Returns a list that contains all the values in the dictionary
This article is from the "Eight Miles" blog, so be sure to keep this source http://5921271.blog.51cto.com/5911271/1721565
Python dictionary functions