转载: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))

  

相关文章:

  • 2021-06-21
  • 2021-12-13
  • 2021-05-10
  • 2021-05-25
  • 2022-01-05
  • 2021-07-03
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-02-13
  • 2022-03-01
  • 2022-12-23
相关资源
相似解决方案