Python 控制结构

if 结构

[python]

if expression1:
suite1
elif expression2:
suite2
else:
suite3

[/python]

while 结构

[python]

while expression:
suite

[/python]

[注]pass 跳过,break 跳出

for 结构

[python]

for variable in iterable:
suite1
else:
suite2
[/python]

[注]

[python]

for i in range(10):
print(i)

[/python]

的结果是:

0
1
2
3
4
5
6
7
8
9