hash table:又称为散列表,有键和值组成,数组中方商品的价格。
散列表总是将同样的输入映射到形同的索引
散列函数将不同的输入映射到不同的索引
散列函数知道数组有多大,只返回有效的索引。
# 投票可以使用散列表
voted={}
def check_voter(name):
if voted.get(name):
print("kick them out")
else:
# 此处可以直接利用ture or false来表示是否投票的
voted[name]=True
print("let them vote")
check_voter("chenxin")
# 将散列表用作缓存
cac