728x90 반응형 counter1 파이썬(Python) collections Counter collections Counter 리스트의 항목 갯수를 셀수 있습니다. 목차 Counter update most_common Counter 항목과 항목 수를 딕셔너리 형태로 리턴 받을 수 있습니다. most_common 가장 많은 빈도를 가진 항목 순으로(내림 차순) 정렬된 딕셔너리 데이터를 받을 수 있습니다. update 기존 항목에 다른 항목을 추가할 수 있습니다. 코드 from collections import Counter list1 = ['a', 'a', 'b', 'c', 'd', 'c'] list2 = ['b', 'b', 'b'] count = Counter(list1) print('result #1: ', count) count.update(list2) print('result #2: ',.. 2021. 9. 22. 이전 1 다음 728x90 반응형