DEV/Python

collections.Counter

young.gratia 2021. 7. 19. 10:42

https://docs.python.org/3/library/collections.html#collections.Counter

 

collections — Container datatypes — Python 3.9.6 documentation

collections — Container datatypes Source code: Lib/collections/__init__.py This module implements specialized container datatypes providing alternatives to Python’s general purpose built-in containers, dict, list, set, and tuple. namedtuple() factory f

docs.python.org

 

Counter is a dict subclass for counting hashable objects. It is a collection where elements are stored as dictionary keys and their counts are stored as dictionary values. Counts are allowed to be any integer value including zero or negative counts. The Counter class is similar to bags or multisets in other languages.

이야 이런게 있었다니! 파이썬 뭐야 넘 멋져~