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('---')
本文共 236 字,大约阅读时间需要 1 分钟。
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('---')
转载于:https://www.cnblogs.com/panfengde/p/10563613.html