##chain## chain函数,连接多个可迭代对象。 from itertools import chain test = chain('AB', 'CDE', 'F') for el in test: print el函数
##combinations(iterable, r):## 建立一个迭代器,返回iterable中全部长度为r的子序列,返回的子序列中的项按输入iterable中的顺序排序: from itertools import combinations test = combinations([1,2,3,4,5], 3) for el in test: print elcode
(1, 2, 3) (1, 2, 4) (1, 2, 5) (1, 3, 4) (1, 3, 5) (1, 4, 5) (2, 3, 4) (2, 3, 5) (2, 4, 5) (3, 4, 5)
##repeat(object [,times]) 重复times次## a = repeat([1,2], 10) for i in a: print i对象