Python range
来源:互联网 发布:保温杯十大排名 知乎 编辑:程序博客网 时间:2024/05/16 07:21
range is a Python function for integer number
1、range(int_num),输出一个从0-(int_num-1)的list
range(10)[0,1,2,3,4,5,6,7,8,9]
2、range(start, end),输出一个从start到end-1的list
range(1,5)1,2,3,4
3 range(start, end, steps) will product a list from start to end by steps. The list`s last element will not larger than end - 1.
range(1,6,2)[1,3,5]range(2,6,2)[2,4]
frange is a Python function for float number, its head file is pylab. You should import pylab when you use this function.
1 frange(int_num) will product a list from 0 to int_num
pylab.frange(4)[ 0. 1. 2. 3. 4.]# it`s from 0 to 42 frange(start, end) will product a list from start to end and the step is 1.0
print pylab.frange(1,4)[ 1. 2. 3. 4.]3 frange(start, end, steps) will product a list from start to end by steps.
pylab.frange(1,4,0.5)[ 1. 1.5 2. 2.5 3. 3.5 4. ]pylab.frange(1,4.4,0.5)[ 1. 1.5 2. 2.5 3. 3.5 4. 4.5]
xrange is a Python function. Its use and parameters are same with range. But it is looked as a type and return an object, the object is iterable, rather than a list. It is faster and less memory than range
>>>xrange(1,3)# produce a objectxrange(1,3)>>>x = xrange(1,3)>>>xxrange(1,3)>>>x[1]2>>>range(1,3)# produce a list[1,2]
阅读全文
0 0
- python--range()
- python range
- python range()
- python range()
- 【python】range()
- Python range
- python for in range
- Python中的range()函数
- python range与xrange
- Python中range
- python的range函数
- python range和xrange
- Python中的range函数
- python中range函数
- python range 和 xrange
- Python range和xrange
- python range xrange
- python for 中的range
- 【Python】Python3 List max()方法
- CRC冗余校验算法&&MTU
- java
- matlab2c使用c++实现matlab函数系列教程-reshape函数
- 【个人笔记四】ART系统执行类方法流程分析
- Python range
- Linux开发工具(gcc gdb make shell)——动态库和静态库比较
- 浏览器升级提示网站:《快乐浏览》
- Apache Ant一个基于Java的生成工具
- ALV复制内容到剪贴板
- Robinson Compass Masks
- 使用xshell-ssh连接服务器被经常意外中断(Disconnected from remote host)
- 开发一个基于ZXing库以及安卓Studio的二维码扫描小程序(二)
- Kafka配置SSL(云环境)