我正在使用Python 3.8,我在徘徊,是否有办法像这样一步一步地完成两个步骤:
for i in range(15):
if i == 2:
# make two steps
else:
#continue normaly
答案 0 :(得分:1)
手动操作生成器
gen = iter(range(15))
while True:
try:
i = next(gen)
if i ==2:
next(gen)
continue
else:
pass
except: StopIteration
break