pythonrange是什么意思
pythonrange()函数可创建一个整数列表,一般用在for循环中。
函数语法
range(start,stop[,step])
参数说明:
start:计数从start开始。默认是从0开始。例如range(5)等价于range(0,5);
stop:计数到stop结束,但不包括stop。例如:range(0,5)是[0,1,2,3,4]没有5
step:步长,默认为1。例如:range(0,5)等价于range(0,5,1)
实例
>>>range(10)#从0开始到10
[0,1,2,3,4,5,6,7,8,9]
>>>range(1,11)#从1开始到11
[1,2,3,4,5,6,7,8,9,10]
>>>range(0,30,5)#步长为5
[0,5,10,15,20,25]
>>>range(0,10,3)#步长为3
[0,3,6,9]
以上内容为大家介绍了python培训之range是什么意思,希望对大家有所帮助,如果想要了解更多Python相关知识,请关注IT培训机构:千锋教育。

相关推荐HOT
更多>>
python流式读取大文件的两种方法
python流式读取大文件的两种方法1、使用read方法分块读取使用更底层的file.read()方法,与直接循环迭代文件对象不同,每次调用file.read(chunk_...详情>>
2023-11-14 16:48:08
pythongreenlet如何交替运行
pythongreenlet如何交替运行1、greenlet说明greenlet是一个基于Greenlet实现的网络库,它使用greenlet来实现协同程序。其基本思想是,当greenle...详情>>
2023-11-14 14:52:57
python收集参数的调用顺序
python收集参数的调用顺序本文教程操作环境:windows7系统、Python3.9.1,DELLG3电脑。1、说明收集参数,关键字参数,普通参数可以混合使用使用...详情>>
2023-11-14 13:23:09
python实例属性的优先级分析
python实例属性的优先级分析1、说明当在实例上给类属性赋值时,实际上是给这个实例绑定了同名的属性而已,并不会影响类属性和其他实例。使用实...详情>>
2023-11-14 10:17:33