先来看看range与xrange的用法介绍 help(range)Help on built-in function range in module __builtin__: range(...) range(stop) -> list of integers range(start, stop[, step]) -> list of integers Return a list containing an arithmetic progression of integers. range(i…
我目前使用的版本是2.7.6 >>> help (range)Help on built-in function range in module __builtin__: range(...) range(stop) -> list of integers range(start, stop[, step]) -> list of integers Return a list containing an arithmetic progression of integers.…
range(start,stop,step): 1.用于循环时使用,可以给定开始,结束,和步长 例如: >>> for i in range(2,10,2):... print i,...2 4 6 8 2.也可以不给定步长,默认是1 例如: >>> for i in range(1,5):... print i,...1 2 3 4 3.也可以不给定结尾,默认从0开始 例如: >>> for i in range(5):... print i,...…