파이썬 라이브러리
조합,순열
순열
from itertools import permutations
print(list(permutations([1,2,3,4], 2)))
print(list(permutations([1,2,3,1], 2)))
# result1
# [(1, 2), (1, 3), (1, 4), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (3, 4), (4, 1), (4, 2), (4, 3)]
# result2
# [(1, 2), (1, 3), (1, 1), (2, 1), (2, 3), (2, 1), (3, 1), (3, 2), (3, 1), (1, 1), (1, 2), (1, 3)]
조합
from itertools import combinations
print(list(combinations([1,2,3,4], 2)))
print(list(combinations([1,2,3,1], 2)))
# result1
# [(1, 2), (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
# result2
# [(1, 2), (1, 3), (1, 1), (2, 3), (2, 1), (3, 1)]
카운터
from collections import counter
키,값으로 값에 키에 대한 횟수로 바꿔준다
Counter('hello world') # Counter({'l': 3, 'o': 2, 'h': 1, 'e': 1, ' ': 1, 'w': 1, 'r': 1, 'd': 1})
Author And Source
이 문제에 관하여(파이썬 라이브러리), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@refindmysapporo/파이썬-라이브러리저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)