def fib(max):
n,a,b=0,0,1
while(n<max):
print(b)
a,b=b,a+b
n=n+1
return'done'
g=fib(6)
while true:
try:
x=next(g)
print('g:',x)
except StopIteration as e:
print('Generator return value:',e.value)
break
错误原因:
except StopIteration as e:
^
IndentationError: unindent does not match any outer indentation level
Nelson_Zhao
相关分类