python
코루틴 예제
easy16
2020. 1. 22. 12:18
def num_coroutine():
total = 0
while True:
print('before yield')
x = (yield total)
total += x
print('after yield')
print(x)
except GeneratorExit:
print('close coroutine')
co = num_coroutine()
print('total',next(co))
print('total', co.send(int(input('put int:'))))
print('total', co.send(int(input('put int:'))))
print('total', co.send(int(input('put int:'))))
co.close()