我想在python中动态生成组合,我有一个varsessionperweeks
(介于2和6之间)
if sessionperweeks==2
for i in range(0,7):
for j in range(i+1,7):
combins.append([i,j])
if sessionperweeks==3
for i in range(0,7):
for j in range(i+1,7):
for k in range(j+1,7):
combins.append([i,j,k])
等等
现在,使用
combinations
fromitertools
从0-6中选择每周的会话:使用2运行的示例(自OP更新后):
运行示例:
相关问题 更多 >
编程相关推荐