Python09之range函数(BIF内置函数)

具体语法:

  range(起始值,结束值,步进值)

range() 其属于内置函数,不需要导入其他模块即可使用,直接在Python的IDLE直接可以使用。

 1 list(range(0,10))
 2 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
 3 list(range(0,11,2))
 4 [0, 2, 4, 6, 8, 10]
 5 list(range(0,11,1))
 6 [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
 7 list(range(11,1,-1))
 8 [11, 10, 9, 8, 7, 6, 5, 4, 3, 2]
 9 list(range(11,1,-2))
10 [11, 9, 7, 5, 3]

猜你喜欢

转载自www.cnblogs.com/ksht-wdyx/p/11308717.html