python中while循环

 

1、

>>> a = ""
>>> while a != "quit":
    a = input("please input a str or 'quit' to leave: ")
    print(a)

    
please input a str or 'quit' to leave: 100
100
please input a str or 'quit' to leave: abc
abc
please input a str or 'quit' to leave: quit
quit

 

2、

>>> a = ""
>>> while a != "quit":
    a = input("please input a str or 'quit' to leave: ")
    if a != "quit":
        print(a)

        
please input a str or 'quit' to leave: 200
200
please input a str or 'quit' to leave: abc
abc
please input a str or 'quit' to leave: quit
>>> 

 

posted @ 2021-01-02 12:38  小鲨鱼2018  阅读(102)  评论(0编辑  收藏  举报