zoukankan      html  css  js  c++  java
  • python从入门到实践-5章if语句

    #!/user/bin/env python

    cars = ['audi','bmw','subaru','toyota']
    for car in cars:
    if car == 'bmw':
    print(car.upper())
    else:
    print(car.title())

    # == !=
    # <= >=
    # and or
    # in not in
    # True False
    # if-else
    # if-elif-elif-else # 选择一个执行
    requesed_toppings = ['mushrooms','green peppers','extra cheese']
    for requesed_topping in requesed_toppings:
    if requesed_topping == 'green peppers':
    print("Sorry,we are out of green peppers now.")
    else:
    print("Addin" + requesed_topping + ".")
    print(' Finished making your pizza!')


    # 确定列表不是空
    requesed_toppings = []
    if requesed_toppings:
    for requesed_topping in requesed_toppings:
    print("Adding" + requesed_topping + ".")
    print(" Finished making your pizza!")
    else:
    print("Are you sure you want a plain pizza?")

  • 相关阅读:
    echo
    shell
    grub
    find
    脚本案例
    dd if= of= MBR
    cat <<EOF> file
    fieldset——一个不常用的HTML标签
    闪烁图片
    跑马灯效果
  • 原文地址:https://www.cnblogs.com/vwei/p/9879982.html
Copyright © 2011-2022 走看看