ITER tools.combinations (iterable,r )从可迭代对象iterable中选择r个单元进行组合,并返回生成元组的迭代程序
可互换, r ) : #组合),2 )-- abacadbcbdcd #组合范围)4), 3---- 012013023123 pool=tuple (iterable ) n=len (pool ) ifrn : return indices=list (range (r ) yieldtuple ) pool=in-r : break else : return indices [ I ]=1forjinrange (i1,r ) : indices [ j ]=indices [ j-1 ]1yeld tuple )
应用枚举验证6174(python编程实验8 )