您的位置:首页 > 编程语言 > Python开发

Python 内建函数 - next(iterable[, default])

2017-03-20 11:15 357 查看
Manual

直译

实例

拓展阅读

Manual

Retrieve the next item from the iterator by calling its __next__() method. If default is given, it is returned if the iterator is exhausted, otherwise StopIteration is raised.

直译

通过调用迭代器的__next__()方法来检索它的下一项。如果给定default,当迭代尽时将返回这个值,否则引发StopIteration。

实例

>>> a = [1, 2, 3, 4, 5]
>>> a = iter([1, 2, 3, 4, 5])
>>> next(a)
1
>>> next(a)
2
>>> next(a)
3
···


拓展阅读

iter()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python