Python dictionary contains the following built-in method:
No. | Functions and Description |
---|---|
1 | dict.clear () All elements in the deleted dictionary |
2 | dict.copy () Returns a shallow copy of the dictionary |
3 | dict.fromkeys (seq [, val]) creates a new dictionary, the sequence elements do seq dictionary key, val a dictionary initial value corresponding to all keys |
4 | dict.get (key, default = None) Returns the specified key, if the return value is not in the dictionary default value |
5 | dict.has_key (key) if the key is in the dictionary dict returns true, otherwise returns false |
6 | dict.items () to return may traverse the list (key, value) tuples array |
7 | dict.keys () to return a list of all the keys dictionary |
8 | dict.setdefault (key, default = None) and get () is similar, but if the key does not exist in the dictionary, and will add value to default keys |
9 | dict.update (dict2) to dict2 dictionary of key / value pairs in the update to the dict |
10 | dict.values () all values in the list returned dictionary |
11 | pop (key [, default]) value of a given key to delete the dictionary corresponding to the key, the return value is deleted. key value must be given. Otherwise, return default values. |
12 | popitem () to go back and delete the last pair of keys and values in the dictionary. |