错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

Built-in Data Structure: Dictionary

  • A. Lakshmi Muddana,
  • Sandhya Vinayakam

摘要

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.