python之yield 的用法
转载:https://blog.csdn.net/mieleizhi0522/article/details/82142856
def foo(): print("starting...") while True: res = yield 4 #yield 看成一个rutrue print("res:",res) g = foo() print(next(g)) print("*"*20) #print(next(g)) print(g.send(9)) #g.send可以直接转入参数进去 print(next(g))