博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
购物车续一
阅读量:5319 次
发布时间:2019-06-14

本文共 3872 字,大约阅读时间需要 12 分钟。

product={}product["001"]={
"Name":"美式面包","Unit":"个","Price":10.00,"Class":"西点类","integral":20.00}product["002"]={
"Name":"法式面包","Unit":"个","Price":15.00,"Class":"西点类","integral":30.00}product["003"]={
"Name":"日食面包","Unit":"个","Price":8.00,"Class":"西点类","integral":16.00}product["004"]={
"Name":"法国啤酒","Unit":"瓶","Price":20.00,"Class":"酒类","integral":40.00}product["005"]={
"Name":"巴西扎啤","Unit":"听","Price":12.00,"Class":"酒类","integral":24.00}product["007"]={
"Name":"国窖100ml","Unit":"瓶","Price":98.00,"Class":"酒类","integral":196.00}product["009"]={
"Name":"美国红苹果","Unit":"Kg","Price":18.00,"Class":"水果类","integral":36.00}product["010"]={
"Name":"日本红富士","Unit":"Kg","Price":12.00,"Class":"水果类","integral":24.00}product["012"]={
"Name":"菲律宾香蕉","Unit":"Kg","Price":9.80,"Class":"水果类","integral":19.60}product["013"]={
"Name":"大白菜","Unit":"Kg","Price":6.00,"Class":"蔬菜类","integral":12.00}product["014"]={
"Name":"黄瓜","Unit":"Kg","Price":5.60,"Class":"蔬菜类","integral":11.20}product["015"]={
"Name":"西兰花","Unit":"Kg","Price":10.00,"Class":"蔬菜类","integral":20.00}product["016"]={
"Name":"大黄鱼","Unit":"Kg","Price":80.00,"Class":"海鲜类","integral":160.00}product["017"]={
"Name":"黄刺鱼","Unit":"Kg","Price":50.00,"Class":"海鲜类","integral":100.00}product["018"]={
"Name":"带鱼","Unit":"Kg","Price":6.00,"Class":"海鲜类","integral":12.00} a=input("请输入”注册”创建账号:")if a=="注册": user1=input("请输入姓名:") sex=input("请输入性别:") userku=input("请输入账号:") psdku=input("请输入密码:") print("注册成功,请登入账号")user=input("请输入账号:")psd=input("请输入密码:")if user==userku and psd==psdku: print("欢迎尊敬的"+user1+"进入商店") print("个人信息:") hyjb=print("会员等级为:普通") jf=0.00; print("姓名:"+user1) print("性别:"+sex)else : print("账号密码错误!")BuyGoods={}good_index = input('请输入商品名称搜索(输入“Buy”退出):')while good_index!='Buy': for key1 in product: if product[key1]["Name"].find(good_index)!=-1: tmpclass=product[key1]["Class"] print("请选择商品编号:") for key2 in product: if product[key2]["Class"].find(tmpclass)!=-1: print("商品编号:{0:.3} {1} 计价单位:{2} 单价:{3:.2f} 积分:{4:.2f}".format(key2,product[key2]["Name"],product[key2]["Unit"],product[key2]["Price"],product[key2]["integral"])) selected_good,Qty = input('请输入购买的3位编码、数量(空格隔开)|"end 0"退出:').split() while selected_good!='end': if len(selected_good)==3 and product[selected_good]!="": BuyGoods[selected_good]={
"Name":product[selected_good]["Name"],"Unit":product[selected_good]["Unit"],"Price":product[selected_good]["Price"],"integral":product[selected_good]["integral"],"Qty":eval(Qty)} selected_good,Qty = input('请输入购买的3位编码、数量(空格隔开)|"end 0"退出:').split() break good_index = input('请输入商品名称搜索(输入“Buy”退出):')SubTotal=0.00;print("*************结算**************")print("你购买的商品、金额如下:")for key3 in BuyGoods: print("商品编号:{0:.3} {1} 计价单位:{2} 单价:{3:.2f} 积分:{4:.2f}".format(key3,BuyGoods[key3]["Name"],BuyGoods[key3]["Unit"],BuyGoods[key3]["Price"],BuyGoods[key3]["integral"],BuyGoods[key3]["Qty"])) SubTotal+=BuyGoods[key3]["Price"]*BuyGoods[key3]["Qty"] if hyjb=="普通": jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*1 elif hyjb=="高级": jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*1.5 elif hyjb=="银钻": jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*2 elif hyjb=="金钻": jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*3 elif hyjb=="黑钻": jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*6 else: jf+=BuyGoods[key3]["integral"]*BuyGoods[key3]["Qty"]*0.5 print("======合计金额为:{:.2f}元".format(SubTotal),"获得积分:",int(jf)) print("信息更新成功!!!") print("姓名:",user1) print("性别:",sex) print("会员等级:银钻","当前积分:",int(jf))

 

转载于:https://www.cnblogs.com/www666666/p/10942939.html

你可能感兴趣的文章
机器学习/深度学习/其他开发环境搭建记录
查看>>
xml.exist() 实例演示
查看>>
判断是否为空然后赋值
查看>>
zabbix监控日志文件
查看>>
正则表达式
查看>>
pip install torch on windows, and the 'from torch._C import * ImportError: DLL load failed:' s...
查看>>
java基础(一):我对java的三个环境变量的简单理解和配置
查看>>
arcgis api 4.x for js 结合 Echarts4 实现散点图效果(附源码下载)
查看>>
YTU 2625: B 构造函数和析构函数
查看>>
apache自带压力测试工具ab的使用及解析
查看>>
C#使用Xamarin开发可移植移动应用(2.Xamarin.Forms布局,本篇很长,注意)附源码
查看>>
jenkins搭建
查看>>
C#中使用Split分隔字符串的技巧
查看>>
加固linux
查看>>
IPSP问题
查看>>
10.17动手动脑
查看>>
WPF中Image显示本地图片
查看>>
Windows Phone 7你不知道的8件事
查看>>
实用拜占庭容错算法PBFT
查看>>
java的二叉树树一层层输出,Java构造二叉树、树形结构先序遍历、中序遍历、后序遍历...
查看>>