dictionary(map、关联数组)存储 key → value 关联,允许您在 average O(1) 时间内通过其 key 查找 value。set 本质上是一个只有 key 没有 value 的 map — 它只存储成员关系。
示例
python
text = .split()
counts = {}
word text:
counts[word] = counts.get(word, ) +
ages = {: , : }
ages[]
ages[] =
ages
