break and continue

  • A+
所属分类:杂谈天下

“一个小例子, 让你再也不头痛break和continue的区别


if __name__ == '__main__':

    print("continue:")

    for i in range(5):
        print(f"-------这是第{i+1}次循环")
        if i == 2:
            continue
        print(f"*******我是{i}啊")

    print("break:")

    for i in range(5):
        print(f"-------这是第{i+1}次循环")
        if i == 2:
            break
        print(f"*******我是{i}啊")
weinxin
我的微信公共号
我的微信公招扫一扫

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: