dict.items()
dict.items() is a Python method in the Dictionary Methods category. Returns a view object of all (key, value) pairs as tuples. The syntax is dict.items(). Returns: Items view. A typical example: d = {"a": 1, "b": 2}
list(d.items()) # [("a", 1), ("b", 2)]. A close sibling is dict.get(), which returns the value for key if it exists, otherwise returns default. A close sibling is dict.keys(), which returns a view object of all keys in the dictionary. A close sibling is dict.values(), which returns a view object of all values in the dictionary. A close sibling is dict.update(), which updates the dictionary with key-value pairs from another dict or keyword args. More about this category: Dictionary methods for key-value operations — get, keys, items, update, and more. For a broader walkthrough, read the Dictionary Methods guide. Related Dictionary Methods entries: dict.get(), dict.keys(), dict.values(), dict.update(), dict.pop(), dict.popitem().