Python标准库:内置函数next(iterator[, default])
来源:互联网 发布:无线图像传输 单片机 编辑:程序博客网 时间:2024/04/30 22:46
本函数是返回迭代子下一个元素的值,主要通过调用__next__()方法来实现的。如果default参数有设置,当下一个元素不存在时,就返回default参数的值,否则抛出异常StopIteration。
例子:
#next()l = [1, 3, 4]it = iter(l)print(next(it))print(next(it, 1))print(next(it, 1))print(next(it, 1))print(next(it, 1))
结果输出如下:
1
3
4
1
1
蔡军生 QQ:9073204 深圳
0 0
- Python标准库:内置函数next(iterator[, default])
- Python标准库:内置函数next(iterator[, default])
- Python标准库:内置函数getattr(object, name[, default])
- Python标准库:内置函数max(iterable, *[, key, default])
- Python标准库:内置函数min(iterable, *[, key, default])
- Python标准库:内置函数max(iterable, *[, key, default])
- Python标准库:内置函数abs(x)
- Python标准库:内置函数all(iterable)
- Python标准库:内置函数any(iterable)
- Python标准库:内置函数ascii(object)
- Python标准库:内置函数bin(x)
- Python标准库:内置函数callable(object)
- Python标准库:内置函数chr(i)
- Python标准库:内置函数classmethod(function)
- Python标准库:内置函数dict(**kwarg)
- Python标准库:内置函数dir([object])
- Python标准库:内置函数float([x])
- Python标准库:内置函数frozenset([iterable])
- 必须掌握的常用算法之一
- 通过线程巧为InetAddress.getByName() DNS查询添加超时限制功能
- HDU2457 DNA repair AC自动机上的简单DP
- iOS复习笔记2:Objective-C语法基础
- U3D<<SPACESHOOT>>个人重制版。代码分享(四)游戏控制部分
- Python标准库:内置函数next(iterator[, default])
- tomcat 修改ROOT的方法
- [暖手][学习阶段-各路杂题][HDU-1018]Big Number
- POJ 1088-滑雪(dp)
- 捕鱼和分鱼
- Keil C各个库的作用
- sqlplus命令大全
- Pots(POJ 3414)
- HTML <td> 标签的 valign 属性