我的函數創建發電機的鏈條: def bar(num):
import itertools
some_sequence = (x*1.5 for x in range(num))
some_other_sequence = (x*2.6 for x in range(num))
chained = itertools.chain(some_sequence,
工作,我有這樣的代碼: #opened file f
goto_line = num_lines #Total number of lines
while not found:
line_str = next(itertools.islice(f, goto_line - 1, goto_line))
goto_line = goto_line/2
#checks
import itertools
def _yield_sample():
it = iter(itertools.combinations('ABCD', 2))
it2 = iter(itertools.combinations('EFGH', 3))
itc = itertools.chain(it,it2)
for x in itc: