반응형
반응형

 

itertools.combinations(iterable, r)

  • 파이썬의 combinations은 itertools 라이브러리를 호출해서 사용할 수 있습니다.
  • iterable은 member를 하나씩 반환할 수 있는 object를 말하며, 예로는 sequence type인 list, str, tuple이 있습니다.

 

예시 코드)

combinations('ABCD', 2) --> AB AC AD BC BD CD
combinations(range(4), 3) --> 012 013 023 123
반응형

'Python' 카테고리의 다른 글

[python] list 사용 방법  (0) 2023.05.29
zip()  (0) 2023.05.03
[panda]info()  (0) 2023.04.26
cannot import name 'fl_score' from 'sklearn.metrics'  (0) 2023.04.26
IndentationError: unindent does not match any outer indentation level  (0) 2023.04.25

+ Recent posts