Python—itertools库使用
itertools.product()
重复使用words 3次进行元素间的组合,总共是3×3×3=27中情况。
1 | words = ["word", "good", "best"] |
itertools.combinations()
内部有序自己组合,要求长度小于列表自身长度。
1 | words = ["word", "good", "best"] |
itertools.permutations()
内部无序自组合
1 | words = ["word", "good", "best"] |