zoukankan      html  css  js  c++  java
  • python中while循环

    1、

    >>> a = {}
    >>> while a != "quit":
        a = input("please input an incredient:")
        if a != "quit":
            print(f"{a} will be added!!")
    
            
    please input an incredient:apple
    apple will be added!!
    please input an incredient:abc
    abc will be added!!
    please input an incredient:quit

    2、

    >>> tag = True
    >>> while tag:
        a = input("please input an incrident: ")
        if a != "quit":
            print(f"{a} will be added!!")
        else:
            tag = False
    
            
    please input an incrident: apple
    apple will be added!!
    please input an incrident: 100
    100 will be added!!
    please input an incrident: quit

    3、

    >>> while True:
        a = input("please input an item:")
        if a == "quit":
            break
        else:
            print(f"{a} will be added!!")
    
            
    please input an item:apple
    apple will be added!!
    please input an item:100
    100 will be added!!
    please input an item:quit
  • 相关阅读:
    JAVA多线程之AQS
    LRU算法
    JAVA设计之SPI
    JAVA多线程之CAS
    操作系统之中断处理
    计算机领域思想
    操作系统之I/O
    操作系统之虚拟内存
    Mysql事务原理
    Mysql添加索引
  • 原文地址:https://www.cnblogs.com/liujiaxin2018/p/14222746.html
Copyright © 2011-2022 走看看