python3.x 简单的for语句循环案例

来源:互联网 发布:linux安装hba卡驱动 编辑:程序博客网 时间:2024/06/18 18:51
python简单完成一个for循环并且使用break及continue并查看其效果
#!/usr/bin/env python# Auther by wqfor i in range(0,10):    if i <5:        print("loop",i)    else:        continue    #跳出本次循环进入下一个循环    print("hehe...")print("jump out this recycle")for i in range(10):    print('--------------',i)    for j in range(10):        print(j)        if j >5:            break#跳出本小循环
输出结果:
loop 0hehe...loop 1hehe...loop 2hehe...loop 3hehe...loop 4hehe...jump out this cycle-------------- 00123456-------------- 10123456-------------- 20123456-------------- 30123456-------------- 40123456-------------- 50123456-------------- 60123456-------------- 70123456-------------- 80123456-------------- 90123456Process finished with exit code 0
原创粉丝点击