发布时间:2019-09-16 07:33:29编辑:auto阅读(2272)
例如:
输入为
[‘1’,’2’,’3’]和3
输出为
[‘111’,’112’,’113’,’121’,’122’,’123’,’131’,’132’,’133’,’211’,’212’,’213’,’221’,’222’,’223’,’231’,’232’,’233’,’311’,’312’,’313’,’321’,’322’,’323’,’331’,’332’,’333’]
from itertools import product
l = [1, 2, 3]
print list(product(l, l))
print list(product(l, repeat=3))
例如:
输入为
[1, 2, 3]和2
输出为
[1, 2], [1, 3], [2, 3] 不考虑顺序
from itertools import combinations
l = [1, 2, 3, 4, 5]
print list(combinations(l, 3))
上一篇: python pexpect 模块
下一篇: Python Windows中将Pyth
47842
46390
37283
34733
29313
25973
24916
19951
19545
18030
5792°
6413°
5927°
5961°
7064°
5911°
5944°
6438°
6404°
7778°