Skip to content

range

  • Python中经常使用 range来产生一个数字列表, 一般使用的时候有2个参数,产生的列表范围包含第一个参数,不包含第二个参数。 例子见下面代码
#coding:utf-8

a = range(0,10)
print(a)

b = range(2,4)
print(b)

执行结果

jeapedudeAir-3:examples jeapedu$ python range.py
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[2, 3]