def h():
print 'Wen Chuan',
m = yield 5 # Fighting!
print m
d = yield 12
print 'We are together!'
c = h()
m = c.next() #m gets the value of yield 5
d = c.send('Fighting!') #d gets the value of yield 12
print 'We will never forget the date', m, '.', d
請檢查以上代碼。 它的運行結果低於:爲什麼產量回報值以這種方式改變?
>>> ================================ RESTART ================================
>>>
Wen Chuan Fighting!
We will never forget the date 5 . 12
而且根據我的理解,第一產返回值更改爲「Fighting
!」已經,但爲什麼以後當print m
它仍然顯示值5?