1、流程控制语句for:
1.格式一:
for 变量 in iterable:
pass
1 s = ‘abcd‘ 2 for i in s: 3 print(i)
2.格式二:
for 变量 in iterable:
if 条件:
break(或者continue)
pass
1 s = ‘abcd‘ 2 for i in s: 3 print(i) 4 if i == ‘b‘: 5 break
3.格式三:
for 变量 in iterable:
pass
else:
pass
1 s = ‘abcd‘ 2 for i in s: 3 print(i) 4 else: 5 print(‘打印完成!‘)