Built-in Data Structure: Dictionary
摘要
Dictionary is one of the Pythons’ built-in data structures. A dictionary is a collection of data stored as key-value pairs, enclosed in curly brackets. Key, value are separated by colon and key–value pairs are separated by commas. Unlike other built-in data structures where each element is a single value, a dictionary element is a pair of key and value. The dictionary object maps a set of unique keys to a set of values. Hence, a dictionary is also referred to as an associative array in other programming languages. Initially, the dictionary object was an unordered collection but from Python version 3.7 onwards, it is an ordered collection of key–value items, i.e., the object maintains the insertion order. The dictionary object is mutable with no duplicate keys.