def generator(): print(123) ret = yield 1#第一个next方法执行完之后,send方法传参数赋值给ret print('-----',ret) print(345) yield 2 g = generator() print(g.__next__()) print(g.send('alex'))
def generator(): print(123) ret = yield 1#第一个next方法执行完之后,send方法传参数赋值给ret print('-----',ret) print(345) yield 2 g = generator() print(g.__next__()) print(g.send('alex'))