首页 > 代码库 > python3 迭代器笔记

python3 迭代器笔记

#迭代器
import sys
list=[1,2,3,4]
it=iter(list)
while True:
try:
print(next(it))
except StopIteration:
sys.exit()



#迭代器
it=iter(list)

print(next(it))
print(next(it))
print(next(it))
print(next(it))

python3 迭代器笔记