range:指定范围,生成指定数字。
1. range()
```Python
for i in range(1, 10):
print(i)
```
执行结果为:
```Python
1
2
3
4
5
6
7
8
9
```
2. range()步长
```Python
for i in range(1, 10, 2):
print(i)
```
执行结果为:
```Python
1
3
5
7
9
```
3. range()反向步长
```Python
for i in range(10, 1, -2):
print(i)
```
执行结果为:
```Python
10
8
6
4
2
```