#移动平均值:类似打靶每打一枪看平均环数 def average(): sum = 0 count = 0 avg = 0 while 1: num = yield avg sum+=num count+=1 avg=sum/count g = average() g.__next__() q=g.send(20) q=g.send(15) print(q)
原文地址:https://www.cnblogs.com/li33232/p/11443520.html
时间: 2024-10-17 21:29:54