Python编程——流程控制之while语句
1、while循环退出
[root@cate my_python]# python test_while
hello
please input the value of x,q for quit:hello
hello
please input the value of x,q for quit:a
hello
please input the value of x,q for quit:q
[root@cate my_python]#
[root@cate my_python]# python test_while
hello
please input the value of x,q for quit:a
hello
please input the value of x,q for quit:q
[root@cate my_python]#
2、while和for语句一样,都存在else语句
[root@cate my_python]# python test_while
hello
please input the value of x,q for quit:a
hello
please input the value of x,q for quit:q
else!
[root@cate my_python]#
3、break跳出整个while-else语句块
[root@cate my_python]# python test_while
hello
please input the value of x,q for quit:b
hello
please input the value of x,q for quit:
[root@cate my_python]#