- 论坛徽章:
- 0
|
- def choose():
- print "please send your choose('1'and'2','q' to quit):"
- while True:
- choose=yield
- if choose=='1':
- print 'you have chosen 1,function_1'
- elif choose=='2':
- print 'you have chosen 2,function_2'
- elif choose=='q':
- print 'quit'
- break
- else:
- print "please choose again('1'and'2')"
- c=choose()
- c.next()
- c.send('2')
- c.send('q')
- c.send('3')
- c.send('5')
复制代码 出现错误:
Traceback (most recent call last):
File "C:\Documents and Settings\dsf\My Documents\Aptana Studio 3 Workspace\advance\src\generator_choose.py", line 17, in <module>
c.send('q')
StopIteration
怎么改让程序退出不报错 |
|