sites = ["baidu", "google", "noob", "taobao"] for site in sites: if site == "noob": print("菜鸟教程!") break #跳出循环体 print("循环数据:", site) else: print("没有循环数据") print("完成循环")
结果: