python next() 方法的问题 10
deffunc():x=0whileTrue:x+=1yieldxprint(next(func()))print(next(func()))print(next(fun...
def func():
x = 0
while True:
x += 1
yield x
print(next(func()))
print(next(func()))
print(next(func()))
#返回值1 1 1
f=func()
print(next(f))
print(next(f))
print(next(f))
#返回值1 2 3
既然f=func()
为什么next(func())没有进入循环,next(f)可以正常迭代? 展开
x = 0
while True:
x += 1
yield x
print(next(func()))
print(next(func()))
print(next(func()))
#返回值1 1 1
f=func()
print(next(f))
print(next(f))
print(next(f))
#返回值1 2 3
既然f=func()
为什么next(func())没有进入循环,next(f)可以正常迭代? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询