python学习笔记 -- iter(): 手动迭代

scores = [88, 79, 65, 96, 75, 68, 91.5]

#手动迭代: iter(可操作序列), 返回一个迭代器
i = iter(scores)
while True:
    try:
        s = next(i)
    except StopIteration:
        break
    print(s)

操作结果:
88
79
65
96
75
68
91.5

posted @ 2017-04-24 11:59  C/C++/Python/Java  阅读(266)  评论(0编辑  收藏  举报