首页 > 编程语言 > 详细

python的collections应用为字典哈希

时间:2018-11-09 17:31:18      阅读:204      评论:0      收藏:0      [点我收藏+]
import collections
allNum=collections.defaultdict(int)
allNum[1]+=1
allNum[5]+=1
print(allNum)

  当然,defaultdict里面的int,可以换为list,dict等等

换list则为:allNum[1].append(1)即:allNum[key].append(value)

python的collections应用为字典哈希

原文:https://www.cnblogs.com/tangmiao/p/9936224.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!