输入两个参数分别为:可迭代对象,从可迭代对象中取出几个值来计算其排列
>>> from itertools import permutations >>> permutations(a,3) <itertools.permutations object at 0x000002216C0799F0> >>> print(permutations(a,3)) <itertools.permutations object at 0x000002216E117270> >>> type(permutations(a,3)) <class ‘itertools.permutations‘> >>> >>> >>> >>> >>> for i in permutations(‘ABC‘,3): print(i) (‘A‘, ‘B‘, ‘C‘) (‘A‘, ‘C‘, ‘B‘) (‘B‘, ‘A‘, ‘C‘) (‘B‘, ‘C‘, ‘A‘) (‘C‘, ‘A‘, ‘B‘) (‘C‘, ‘B‘, ‘A‘) >>> >>> for i in permutations(a,3): print(i) (1, 2, 3) (1, 3, 2) (2, 1, 3) (2, 3, 1) (3, 1, 2) (3, 2, 1) >>>