Python
Python copied to clipboard
python 迭代器 -元组
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。请看看是不是循环条件有问题。谢谢