zoukankan      html  css  js  c++  java
  • 购物车简例

    # v# -*- coding: utf-8 -*-
    # """
    # Created on Fri Aug 23 14:23:55 2019
    #
    # @author: ITS
    # """
    #
    # total_money = int(input('user money:
    '))
    # goods = [
    #     {"name": "电脑", "price": 1999},
    #     {"name": "鼠标", "price": 10},
    #     {"name": "游艇", "price": 20},
    #     {"name": "美女", "price": 998},
    # ]
    # buylist_id=[]
    # buylist = []
    # goods_list = []
    # money = []
    # goods_money = 0
    #
    # def listgoods():
    #     for i in goods:
    #         print(i)
    #
    # def addcar():
    #     global goods_money,goods_list
    #     i = int(input('choose your goods index:
    '))
    #     if i not in range(len(goods)):
    #         print("error , no good there")
    #     else:
    #         buylist.append(goods[i])
    #         buylist_id.append(i)
    #         print(buylist_id)
    #         goods_list=buylist[:]
    #         print(goods_list)
    #     CHOICE = input('continue buy? : Y/N
    ')
    #     if CHOICE == 'Y':
    #         addcar()
    #     elif CHOICE == 'N':
    #         print('jiesuanzhong')
    #
    #
    #
    #     return buylist_id,buylist,goods_list,goods_money
    #
    # def jiesuan():
    #     global total_money,goods_list,goods_money
    #     for i in range(len(goods_list)):
    #         money.append(goods_list[i]['price'])
    #     #print(money)
    #     for item in money:
    #         goods_money += item
    #     print(goods_money)
    #     while goods_money>total_money:
    #         CHOICE = input('addmoney? : Y/N
    ')
    #         if CHOICE == 'Y':
    #             num = int(input('choose your addmoney number:
    '))
    #             addmoney(num)
    #             while goods_money>total_money:
    #                 num1 = int(input('please continue addmoney:
    '))
    #                 addmoney(num1)
    #             total_money-=goods_money
    #             #print('total_money:',total_money)
    #             print('purchase success, rest_money:',total_money)
    #             break
    #
    #         elif CHOICE == 'N':
    #             choice = input("remove some goods? : Y/N
    ")
    #             if choice == 'Y':
    #                 print(buylist_id)
    #                 i = int(input('choose your remove good: 
    '))
    #                 if i not in buylist_id:
    #                     print('error, have not chosen this good')
    #                 elif i in buylist_id:
    #                     buylist_id.remove(i)
    #                     print(buylist_id)
    #                     item = 0
    #                     new_total_money= []
    #                     for i in buylist_id:
    #                         new_total_money.append(goods[i]['price'])
    #                     for new_money in new_total_money :
    #                         item += new_money
    #                         goods_money=item
    #                     print(goods_money)
    #                     total_money-=goods_money
    #                     print('purchase success, rest money:',total_money)
    #                     break
    #             elif choice == 'N':
    #                 print('purchase failed')
    #                 break
    #
    # def addmoney(num):
    #     global total_money
    #     total_money += num
    #     return total_money
    #
    #
    # if __name__ == "__main__":
    #     addcar()
    #     jiesuan()
    

      

  • 相关阅读:
    MySQL 卸载
    Mysql(压缩包)下载与安装
    sqlserver一次性修改多条
    mysql一些操作
    SQL函数集合
    js时间转换相关
    easyui grid中翻页多选方法
    easyui combobox筛选(拼音)
    wpf图片切换,幻灯效果
    openfire搭建IM
  • 原文地址:https://www.cnblogs.com/njuwyx/p/11656543.html
Copyright © 2011-2022 走看看