标签:value break int exception class except exce color bsp
def fib(num): a, b = 0, 1 index = 0 while index < num: yield a a, b = b, a+b index += 1 return ‘ok...‘ f = fib(100) while True: try: print(next(f)) except Exception as e: print(e.value) break # for num in f: # print(num)
def fib(num): a, b = 0, 1 index = 0 while index < num: temp = yield a print(‘temp:‘,temp) a, b = b, a+b index += 1 f = fib(20) ret = next(f) print(ret) ret2 = f.send(‘test‘) print(ret2)
标签:value break int exception class except exce color bsp
原文地址:https://www.cnblogs.com/kuraki/p/9641568.html