defcountdown(n):print"conuntingdownform",nwhilen>=0:print"firstn:",nnewvalue=(yieldn)print"secondn:",nprint"firstnewvalue",newvalueifnewvalueisnotNone:n=newvalueelse:n-=1print"secondnewvalue",newvaluec=countdown(5)forninc:#printnifn==5:c.send(3)输出结果:conuntingdownform5firstn:5secondn:5firstnewvalue3secondnewvalue3firstn:3secondn:3firstnewvalueNonesecondnewvalueNonefirstn:2secondn:2firstnewvalueNonesecondnewvalueNonefirstn:1secondn:1firstnewvalueNonesecondnewvalueNonefirstn:0secondn:0firstnewvalueNonesecondnewvalueNone这个期间发送的send值是不是改变了n的值,是不是会继续进行n=3的迭代?
添加回答
举报
0/150
提交
取消