标签:bre 结束 for循环 tin for 执行 %s continue 循环
1 for a in [1,2,3,4,5]: 2 3 for b in [1,2,3]: 4 if a == b: 5 print("a = b = %s" % a) 6 break # 退出本次for循环,执行第一行的for循环 7 else: 8 print("a = %s" % a) 9 continue # 继续执行第一行的for循环 10 print("结束")
a = b = 1
a = b = 2
a = b = 3
a = 4
a = 5
结束
python 双层for循环,在第二层的for循环中的else中的continue,会退出到第一层for循环继续执行
标签:bre 结束 for循环 tin for 执行 %s continue 循环
原文地址:https://www.cnblogs.com/cfpl/p/12045170.html