Skip to content

Instantly share code, notes, and snippets.

@Everfighting
Last active May 20, 2021 06:36
Show Gist options
  • Save Everfighting/916f410f912992fa64afde27cd4e662a to your computer and use it in GitHub Desktop.
Save Everfighting/916f410f912992fa64afde27cd4e662a to your computer and use it in GitHub Desktop.
from collections import Counter
Counter([1,1,1,2,3,2,2,])
# 返回字典统计key的个数
Counter(list).most_common()
# 常见的几个
from collections import defaultdict
nums = defaultdict(int)
nums['one'] = 1
nums['two'] = 2
print(nums['three'])
# 输出为0
from collections import OrderedDict
# 输出顺序字典
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment