[python-chinese] 在程序中使用yield报错,SyntaxError: 'return' with argument inside generator (xlrdT3a.py, line 246)
张建轶
farsoftwind在gmail.com
星期四 八月 2 11:11:40 HKT 2007
лл£¡¹ûÈ»ÎÒÓÐÒ»¸öreturnÓÖ·µ»ØÖµ
ÎÊÌâÒѽâ¾ö¡£
ÔÚ07-8-2£¬helium <helium.sun在gmail.com> дµÀ£º
>
> ²»ÊDz»ÄÜreturn£¬¶øÊÇreturn²»ÄÜ´ø²ÎÊý
>
> Ö»ÒªÄãʹÓÃÁËyield£¬Õâ¾Í²»ÊÇÒ»¸öfunctionÁË£¬¶øÊǸögenerator£¬ËùÒÔ·µ»ØÖµÊÇûÓÐÒâÒåµÄ¡£Ò»¸öµ¥¶ÀµÄreturnÓï¾ä´¥·¢Ò»¸öStopIterationÒì³££¬±íʾÄãÕâ¸ögenerator½áÊø¡£
>
> On 8/2/07, »ÆÒã <yi.codeplayer在gmail.com> wrote:
> > ÓÃÁË yield ¾Í²»ÄÜÓà return
> >
> >
> > On 8/1/07, ÕŽ¨éó <farsoftwind在gmail.com> wrote:
> > >
> > > ÓÉÓÚÔ´³ÌÐò±È½Ï³¤£¬¶øÇҺܸ´ÔÓ
> > > ÎÒ¼ò»¯ÁËһϣ¬ÈçÏÂËùʾ£º
> > >
> > > #!/usr/bin/python
> > >
> > > def ff():
> > > for i in range(1,5):
> > > print i
> > > buffc = []
> > > bufbc = []
> > > for j in range(1,4):
> > > print j
> > > buffc.append(u'1')
> > > bufbc.append(u'2')
> > > print buffc
> > > yield buffc
> > >
> > > for ss in ff():
> > > print ss
> > >
> > > µ«Õâ¸ö¼ò»¯³ÌÐòÕýÈ·±àÒëͨ¹ý£¬µ«Ô´³ÌÐò±àÒëʱ±¨´í£¬´íÎóÐÅÏ¢ÈçÏ£º
> > > SyntaxError: 'return' with argument inside generator ( xlrdT3a.py,
> line
> > 246)
> > > ±¨´íµÄ246ÐеijÌÐòÖ»ÊÇÒ»¾ä£º
> > > yield bufxf
> > >
> > > ÇëÎÊÊÇÔõô»ØÊÂÄØ£¿ÈçºÎÐÞÕý£¿Çë½Ì
> > >
> > >
> > >
> > >
> > > _______________________________________________
> > > python-chinese
> > > Post: send python-chinese在lists.python.cn
> > > Subscribe: send subscribe to
> > python-chinese-request在lists.python.cn
> > > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > > Detail Info:
> > http://python.cn/mailman/listinfo/python-chinese
> > >
> >
> >
> >
> > --
> > http://codeplayer.blogspot.com/
> > _______________________________________________
> > python-chinese
> > Post: send python-chinese在lists.python.cn
> > Subscribe: send subscribe to
> > python-chinese-request在lists.python.cn
> > Unsubscribe: send unsubscribe to
> > python-chinese-request在lists.python.cn
> > Detail Info:
> > http://python.cn/mailman/listinfo/python-chinese
> >
> _______________________________________________
> python-chinese
> Post: send python-chinese在lists.python.cn
> Subscribe: send subscribe to python-chinese-request在lists.python.cn
> Unsubscribe: send unsubscribe to python-chinese-request在lists.python.cn
> Detail Info: http://python.cn/mailman/listinfo/python-chinese
-------------- 下一部分 --------------
Ò»¸öHTML¸½¼þ±»ÒƳý...
URL: http://python.cn/pipermail/python-chinese/attachments/20070802/d93835d9/attachment-0001.html
关于邮件列表 python-chinese 的更多信息