1 for <循环变量> in <便利结构>:
语句块
for i in range(m, n, k):设置步长
2 字符串便利循环
for c in s:
语句
for c in ‘python’:
print(c, end = ‘,’)
3 文件:
for line in f:
4 while 条件:
语句
5 break continue
break指打破当前循环
continue跳过这次循环
s = s[:-5]
遍历循环
最新推荐文章于 2024-08-20 08:40:28 发布