Python icon indicating copy to clipboard operation
Python copied to clipboard

python 迭代器 -元组

Open zyxzhangyuxia opened this issue 5 years ago • 0 comments

3、tuple(元祖) 对象创建迭代器

tuple1 = ( 1,2,3,4 ) iter3 = iter ( tuple1 )

next() 函数遍历迭代器

while True : try : print ( next ( iter3 ) ) except StopIteration : break

这个代码的实际运行效果是:1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1。请看看是不是循环条件有问题。谢谢

zyxzhangyuxia avatar Aug 27 '20 03:08 zyxzhangyuxia