通俗地讲,就是返回可迭代对象的所有数学全排列方式。
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import permutations
>>> permutations(['a', 'b', 'c'])
>>> for item in permutations(['a', 'b', 'c']):
... print item
...
('a', 'b', 'c')
('a', 'c', 'b')
('b', 'a', 'c')
('b', 'c', 'a')
('c', 'a', 'b')
('c', 'b', 'a')
>>> for i in itertools.permutations('123', 2):
... print i
...
('1', '2')
('1', '3')
('2', '1')
('2', '3')
('3', '1')
('3', '2')
>>> itertools.permutations('123', 2)