核驗記錄:12_hash_table.txt

與教程配套的原始示例或核驗資料,保留完整內容;其中真實用戶目錄已脫敏,運行範圍以記錄本身為準。

在 100000 个元素中查找: list 492 µs | set 72 ns
get('plum') = 4 | 各桶长度: [2, 1, 2, 1] (字符串哈希每次进程启动都随机化,分布会变)
hash(1) == hash(1.0) == hash(True): True → 字典里它们是同一个键: {1: 'c'}
列表不能做键: unhashable type: 'list'
词频 Top2: [('the', 3), ('and', 2)]
按长度分组: {3: ['the', 'cat', 'and', 'the', 'hat', 'and', 'the', 'bat']}
保序去重: ['the', 'cat', 'and', 'hat', 'bat']

關聯教程

繼續瀏覽教程 返回知識 →返回頂部 ↑
本篇目錄
教程圖解100%
教程圖解