程序流程控制
分支语句
- if
- if-else
- if-elif-else
if missYou:
print("I miss you.")
else:
print("I don't miss you.")
循环语句
- while
遇到break、return、异常,循环会终止。
while missYou:
print("I miss you.")
missYou=False
else:
print("ELSE.")
- for
for item in items:
print(item)
else:
print("ELSE.")
for item in range(1,10):
print(item) # 输出1-9
跳转语句
- break
- continue
- return