#coding:utf-8
#http://www.pythontab.com/html/2015/pythonhexinbiancheng_0415/946.html
'''
d=hehe()不会print,需调用d.next(),或d.send()
d.next()等价于d.send(None)
'''
def hehe():
a=[1,2,3,4,5]
for i in a:
print i
t=yield i
print t
if __name__=='__main__':
d=hehe()
while True:
m=d.next()
d.send(m)
python yield
最新推荐文章于 2022-06-05 09:39:09 发布