摘要:
else: 循环可以和else配合使用,else下方缩进的代码指的是当循环正常结束之后要执行的代码。 while...else正常结束: # 需求:种完5棵树,完成之后回家吃饭 i = 1 while i <= 5: print(f'种完第{i}颗树') i +=1 else: print('终于可 阅读全文
posted @ 2022-08-01 23:38
㞢卄BYZ
阅读(120)
评论(0)
推荐(0)
摘要:
语法: for 临时变量 in 序列: 重复执行的代码 1.准备一个数据序列 2.for ''' int1 = '123456789' for i in int1: print(i) break控制for案例: str1 = 'qwertyu' for i in str1: # 当某些条件成立退出循 阅读全文
posted @ 2022-08-01 23:38
㞢卄BYZ
阅读(87)
评论(0)
推荐(0)

浙公网安备 33010602011771号