shopping cart<代码>
i = ["iphone 6000", "bicycle 1000", "coffee 50", "python book 100", "italy pizza 200", ]
j = ["] # 运用列表嵌套更容易实现
in_list = [] # 已购买物品列表
salary = int(input("你的工资:"))
while salary > 0: # 循环的开始以工资余额大于零开始
# a = 0 # 循环打印利于管理员账户的管理
# while a < 5:
# print("{xuhao}" .format(xuhao=a+1), i[a]) # 生硬的加个序号 下面注释的是更简单的方法
# a += 1
for d, e in enumerate(i, 1):
print(d, ">>>", e)
w_i = input("你想要的物品序号或者退出q")
if w_i.isdigit(): # 判断是否数字(输入的都是字符串)
w_i = int(w_i)
if 0 < w_i <= len(i): # len 计算长度
if salary > int(j[w_i-1]):
salary -= int(j[w_i-1]) # 余额变成工资 接着循环
in_list.append(i[w_i-1]) # 加入购物车列表
print(i[w_i-1], "已加入你的购物车")
else:
print("您的余额不足")
elif w_i == "q":
break
elif w_i == "manager":
print("0:增加商品 1:下架商品 2:修改价格 ")
keyword = int(input("输入命令序号:"))
if keyword == 0:
name_staff = str(input("输入商品名"))
ordor_staff = int(input("输入商品序号"))
price_staff = input("输入价格")
name_staff = " ".join([name_staff,price_staff])
j.insert(ordor_staff-1, price_staff)
i.insert(ordor_staff-1, name_staff)
elif keyword == 1:
ordor_staff = int(input("输入商品序号"))
l = i.pop(ordor_staff - 1)
print("已删除:", l)
elif keyword == 2:
ordor_staff = int(input("修改的序号"))
gai_price = input("修改的价格")
j[ordor_staff-1] = gai_price
f = i[ordor_staff-1] # iho 6000
u = j[ordor_staff - 1] # u =1
v = "".join([f,"降价为"])
i[ordor_staff-1] = " ".join([v,u])
else:
print("眼瞎呀")
else:
print("非法字符")
print("您已经购买:")
for b in in_list:
print(b)
print("您的余额为:", salary)
简易购物车系统
shopping cart<代码>的更多相关文章
- 购物车(Shopping cart) —— B2C网站核心产品设计 (二)
购物车是做什么的? 我们先来看一下现实超市中的购物车,一个带四个轱辘的铁筐子,客人推来推去,看到什么东西喜欢,就扔进去,觉得东西差不多了,就推到收银台. 那B2C网站中的购物车又是一个什么东西呢? 从 ...
- C#集合Collections购物车Shopping Cart
这篇是对象与集合操练,物件的创建,集合的一些基本功能,如添加,编辑,删除等功能. 对象,即是网店的商品物件,Insus.NET只为其添加2个属性,物件的ID的Key和名称ItemName以及2个构造函 ...
- shopping cart
#Author:Kevin_hou #定义产品列表 product_list =[ ('HUAWEI',5999), ('Watch',500), ('Nike',800), ('Toyota',20 ...
- Simple Shopping Cart By AngularJS
<body ng-controller='CartController'> <h1>Your Order</h1> <div ng-repeat='item ...
- PHP之购物车的代码
该文章记录了购物车的实现代码,仅供参考 book_sc_fns.php <?php include_once('output_fns.php'); include_once('book_fns. ...
- Octopus系列之代码备份
代码 $.extend($.validator.messages, { required: "This field is required.", remote: "Ple ...
- magento产品成功添加到购物车后跳转到不同页面 添加 add to cart 按钮
1 添加产品到购物车成功后是跳转到购物车页面或不跳转.这个在后台可以设置 system -> configuration -> After Adding a Product Redirec ...
- 怎样改动、扩展并重写Magento代码
作为一个开发人员的你,肯定要改动Magento代码去适应你的业务需求,可是在非常多时候我们不希望改动Magento的核心代码,这里有非常多原因, 比如将来还希望升级Magento.还想使用很多其它的M ...
- Python学习1,代码
看了好久的网上视频,今天尝试着写了一串代码: _author_ = "Happyboy" produce_list = [ ('Iphone',5800), ('Mac Pro ...
随机推荐
- BZOJ4373 : 算术天才⑨与等差数列
设$pre[i]$表示第$i$个数上一次出现的位置,$d[i]=abs(a[i]-a[i+1])$. 用线段树维护区间内$a$的最小值.最大值,$pre$的最大值以及$d$的$\gcd$. 对于询问$ ...
- BZOJ1105 : [POI2007]石头花园SKA
考虑把所有石头翻到直线y=x同侧,此时可以保证篱笆长度最短. 这种最短的篱笆一共有4种可能,枚举每种可能然后$O(n)$检验求出答案即可. #include<cstdio> const i ...
- HDU 4669 Mutiples on a circle(环状DP)
题目链接 这是最早看懂题意的一题,状态转移,挺好想..但是比赛时候,就是没有想到怎么去重,而且当时有些情况,也没注意到. 先预处理的dp[0]的情况,就是以p[0]为结尾的情况.之后D就行了,例如样例 ...
- sqlserver常用日期、时间函数和格式
Sql Server中常用的日期与时间函数1. 当前系统日期.时间 select getdate() 2. dateadd 在向指定日期加上一段时间的基础上,返回新的 datetime 值 ...
- C++ unordered_map remove 实现哈希表移除
使用C++的unordered_map类型时,我们经常要根据关键字查找,并移除一组映射,在Java中直接用remove即可,而STL中居然没有实现remove这个函数,还要自己写循环来查找要删除项,然 ...
- MLUtils.loadLibSVMFile
import org.apache.spark.mllib.util.MLUtils// Load and parse the data file. val data = MLUtils.loadLi ...
- phpunit安装参考
我主要参考看PHPunit参考手册https://phpunit.de/manual/current/zh_cn/installation.html 然后按照测试成功否检验,参考了http://blo ...
- SQLLite 可以通过SQL语言来访问的文件型SQL数据库
Web Storage分为两类: - sessionStorage:数据保存在session 对象中(临时) - localStorage:数据保存在本地硬件设备中(永久) sessionStorag ...
- [转]动态调用webservice时 ServiceDescriptionImporter类在vs2010无法引用的解决方法
本文转自:http://blog.csdn.net/limlimlim/article/details/8647038 [导读]ServiceDescriptionImporter是创建Web Ser ...
- Cinder相关命令收集
1. 重置状态 source admin-openrc.sh cinder reset-state 51108241-7ffe-44a8-acfa-4cddac8d4793