티스토리 뷰

공부

[Python] counter

승가비 2020. 4. 26. 02:56
728x90
from collections import Counter

Counter('hello world') 
# ({'l': 3, 'o': 2, 'h': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1})

Counter('hello world').most_common() 
# [('l', 3), ('o', 2), ('h', 1), ('e', 1), (' ', 1), ('w', 1), ('r', 1), ('d', 1)]

Counter('hello world').most_common(1) 
# [('l', 3)]

 

https://www.daleseo.com/python-collections-counter/

 

[파이썬] collections 모듈의 Counter 클래스 사용법

Engineering Blog by Dale Seo

www.daleseo.com

https://www.journaldev.com/20806/python-counter-python-collections-counter

 

Python Counter - Python Collections Counter - JournalDev

Python Counter, Python collections Counter, Python Counter most common, least common elements, Python counter elements(), Python Counter delete an element, arithmetic operations.

www.journaldev.com

 

728x90

'공부' 카테고리의 다른 글

[JS] convert hyper link  (0) 2020.04.29
[Spring] swagger  (0) 2020.04.28
[Git] pull & push don't ask password  (0) 2020.04.26
[MySQL] update by multiple condition  (0) 2020.04.26
[Python] split string to char  (0) 2020.04.26
댓글