range函数用于生成一个包含指定范围内的数字序列的可迭代对象,常用于循环中控制循环次数。其语法为:
range(start, stop, step)
例如:
for i in range(1, 10, 2): print(i)
输出结果为:
1 3 5 7 9