zoukankan      html  css  js  c++  java
  • python shopping incomplete code

    #shopping code
    #shopping.py
    #导入登录模块
    import login
    # shop car beginning
    salary = input("请输入工资: ")
    ###判断输入工资是否为整型###
    if salary.isdigit():
    salary = int(salary)
    else:
    print ("salary not digit")
    exit()
    ###打印一句牛逼的话####
    welcome_msg = 'welcome to our shoping mall'
    print(welcome_msg.center(50, '-'))
    ###商品列表####
    shopcar = [
    ('Iphone', 5888),
    ('Mac Air', 8000),
    ('XiaoMi', 19.9),
    ('coffee', 30),
    ('Tesla', 8200),
    ('Bike', 700),
    ('Cloth', 200)
    ]
    for i in enumerate(shopcar):
    index = i[0]
    product = i[1][0]
    p_salary = i[1][1]

    print (index, product, p_salary)

    exit_msg = '你可以输入e或者q退出,啦啦啦'
    print(exit_msg.center(50, '-'))

    while True:
    num = input("33[5;30;43mplease print bianhao:33[0m ")
    if num.isdigit():
    num = int(num)
    ###判断输入编号不能大于7###
    if num > 7:
    print ("输入错误,没有此编号")
    continue
    ##输入编号购买商品###
    num = input("请输入商品编号: ")
    price = shopcar[num][1]
    price_p = shopcar[num][0]
    if salary > price:
    salary -= price
    print ("购买成功,余额为", salary)
    print ("购买的商品为:", price_p)
    else:
    print ("余额不足,请及时充值")
    print ("余额为", salary)
    continue
    ##exit shoping##
    elif num.isalpha():
    num = str(num)
    if num == 'e' or num == 'q':
    print ("余额为", salary)
    bye_msg = 'next to meet you,see you'
    print(bye_msg.center(50, '-'))
    break
    # if price_p():
    # print ("余额为", salary)
    # exit()
    # else:
    # print ("购买成功,余额为", salary)
    # print ("购买的商品为:", price_p)
    # bye_msg = 'next to meet you,see you'
    # print(bye_msg.center(50, '-'))
  • 相关阅读:
    CSS:在input、pre中左边加上一个图标(一行和多行)
    IntelliJ IDEA 15 创建maven项目
    IntelliJ IDEA 15 部署Tomcat及创建一个简单的Web工程
    IntelliJ IDEA 15 安装
    IntelliJ IDEA 15 设置默认浏览器
    Eclipse 创建Maven工程
    Eclipse 安装热部署JRebel
    解决无法删除表,提示被外键约束引用
    MySql创建触发器
    WinServer2008r2 机器时间格式修改
  • 原文地址:https://www.cnblogs.com/alex-note/p/6836770.html
Copyright © 2011-2022 走看看