Skip to content
Python

Dict API Reference

Python dict methods — mutable mapping of hashable keys to values.

By EZ4Code Team

dict

Mutable mapping of hashable keys to arbitrary values.

dict.get(key[, default])

Return value for key, or default if key is missing. Does not raise.

Returns: Any

dict.keys()

Return a view of the dictionary's keys.

Returns: dict_keys

dict.values()

Return a view of the dictionary's values.

Returns: dict_values

dict.items()

Return a view of (key, value) pairs.

Returns: dict_items

dict.update([other])

Update the dict with key/value pairs from other, overwriting existing keys.

Returns: None

dict.pop(key[, default])

Remove key and return its value. Returns default if missing (else raises KeyError).

Returns: Any

dict.setdefault(key[, default])

If key is in the dict, return its value. Otherwise insert key with default and return default.

Returns: Any

More Python API References