用例程来写一个求平均值的算法
#!/usr/local/python/bin/python3 def FunCore(): total=0 counter=0 average=None tmp=yield average while True: total=total+tmp counter=counter+1 average=total/counter tmp=yield average if __name__ =="__main__": fc=FunCore() next(fc) for x in range(10): average=fc.send(x) print(average)