■ permutations 클래스를 사용해 순열(permutation) 리스트를 구하는 방법을 보여준다.
▶ 예제 코드 (PY)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from itertools import permutations sourceList = [1,2,3] permutations1 = permutations(sourceList, 2) targetList = list(permutations1) print(list(targetList)) """ [(1, 2), (1, 3), (2, 1), (2, 3), (3, 1), (3, 2)] """ |