yield生成器
def go(): for x in range(20): if x < 10: yield 1 else: yield 2 yield 'x' result=go() for x in result: print(x) print('---')