Python标准库:内置函数range(stop) range(start, stop[, step])
2015-03-13 08:25
183 查看
本函数是产生一系列序列的数组,返回迭代子。参数stop是终止的数字;参数start是指明开始数列开始值;参数step是数列之间的差值。因此这个函数就是产生以start为起点,以stop为终点,以step为前后项的差值。这里三个参数可以是正整数、负整数或者0。
例子:
结果输出如下:
1,3,5,7,9,
[1, -1, -3, -5, -7, -9]
[0, 1, 2, 3, 4]
蔡军生 QQ:9073204 深圳
例子:
#range() for i in range(1, 10, 2): print(i, end = ',') print('\n') print(list(range(1, -10, -2))) print(list(range(5)))
结果输出如下:
1,3,5,7,9,
[1, -1, -3, -5, -7, -9]
[0, 1, 2, 3, 4]
蔡军生 QQ:9073204 深圳
相关文章推荐
- Python标准库:内置函数range(stop) range(start, stop[, step])
- Python标准库:内置函数range(stop) range(start, stop[, step])
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- python的内建函数(BIF)range(start, stop, step)
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- Python标准库:内置函数slice(stop) slice(start, stop[, step])
- range([start], stop[, step]):产生一个序列,默认从0开始
- Python标准库:内置函数enumerate(iterable, start=0)
- 关于一道练习题,使用range(start, end, step)
- Python 守护进程 实现 start stop restart
- [转载]Python标准库:内置函数sum(iterable[, start])
- python decimal range() step value
- range 的实现细节(start、end、step)(左闭右开区间)
- Python标准库:内置函数sum(iterable[, start])
- Python标准库:内置函数enumerate(iterable, start=0)
- Python标准库:内置函数sum(iterable[, start])
- Python处理Thread的方式start, stop回收
- Python 内建函数 - range(stop)
- how to start/stop/restart HTTP Server(如何启动/停止/重启HTTP服务器)