编程论坛
注册
登录
编程论坛
→
Python论坛
求1、2、3、4、5、6六个数组成不排序不重复的4位组合。
trivws
发布于 2023-02-13 23:49, 713 次点击
1234和2134也算重复。
1 回复
#2
mrexcel
2023-02-16 18:02
from
itertools
import
combinations
t=[
''
.join(x)
for
x
in
list(combinations(
"
123456
"
, 4))]
print
(t)
['1234', '1235', '1236', '1245', '1246', '1256', '1345', '1346', '1356', '1456', '2345', '2346', '2356', '2456', '3456']
1