Python 3 内置函数 - next()
函数
0. next()
函数
- 返回迭代器的下一个项目。
- 要和生成迭代器的 iter() 函数一起使用。
1. 使用方法
>>> help(next)
# output:
Help on built-in function next in module builtins:
next(...)
## 使用方法:
next(iterator[, default])
Return the next item from the iterator. If default is given and the iterator
is exhausted, it is returned instead of raising StopIteration.
2. 使用示例
>>> a = [0,1,2,3,4]
>>> a = iter(a)
>>> next(a), next(a)
# output:
(0, 1)