from itertools import *
for i in chain([1, 2, 3], ['a', 'b', 'c']):
print(i)
print
for i in zip([1, 2, 3, 4, 5], ['a', 'b', 'c', 'd']):
print(i)
for i in islice(count(), 0, 100, 10):
print(i)
r = islice(count(), 6)
i1, i2 = tee(r)
for i in r:
if i > 1:
break
print(list(i1))
print(list(i2))
for i in map(lambda x, y: (x, y, x * y), range(6), range(6, 12)):
print(i)
print("start map")
values = [(0, 5), (1, 6)]
for i in starmap(lambda x, y: (x, y, x * y), values):
print(i)
for i in zip(count(1), ['a', 'b', 'c']):
print(i)
for i in zip(range(8), cycle(['a', 'b', 'c'])):
print(i)
for i in repeat("aa", 3):
print(i)
for i in zip(repeat('aaa', 5), count()):
print(i)
for i in map(lambda x, y: (x, y, x * y), repeat(2), range(5)):
print(i)
def should_drop(x):
print(x)
return x < 1
for i in dropwhile(should_drop, [-1, 0, 1, 2, -2, ]):
print(i)
python(2)
最新推荐文章于 2023-08-03 21:43:18 发布