淘淘购物系统 (Python)
#首页def tao_first(): t1 = '欢迎进入淘淘购物'.center(110) print(t1) print('~' * 130) t2 = '注册'.center(20) print(t2,end='\t') t3 = '登陆'.center(65) print(t3,end='\t') t4 = '退出'.center(45) print(t4,end='\t') print() print('~' * 130) ##购物车首页def tao_second(): second0 = '|| 购物车 ||'.center(125) print(second0) print() print('=' * 130) print('商品名称',end='\t') print('价格',end='\t') print('数量',end='\t') print('\n') for i in sprice: print(i) print('-' * 130) print('提交订单'.center(20),end='\t') print('删除订单'.center(65),end='\t') print('添加订单'.center(45),end='\t') print('\n') print('查看订单'.center(20),end='\t') print('继续购物'.center(65),end='\t') print('退出系统'.center(45),end='\t') print('\n') print('=' * 130)
#登陆shop_name = ''def login(): l0 = '|| 登陆 ||'.center(115) print(l0) i = 3 while i > 0: username = input('please input the username :') password = input('please input the password : ') if username in lisl[0::2] and password in lisl[1::2] : wage.append(username) wage.append(0) shop_name = username break else: i -= 1 print('验证失败,请再次尝试,您还有'+str(i)+'次机会') continue#注册def enter(): while 1: e0 = '|| 注册 ||'.center(115) print(e0) e1 = input('请输入用户名:') e2 = input('请输入密码:') e3 = input('请再次确认密码:') if e3 == e2 and e1 not in lisl: print('恭喜你注册成功,快去登陆吧...') lisl.append(e1) lisl.append(e3) break if e3 != e2 : print('对不起你输入的密码两次不一致,请重新注册') continue if e1 in lisl: print('对不起你输入的账户信息已存在,请重新注册') continue#工资def staff_wage(): """ wage = [uername : wage] shop_name = uername :return: """ while 1: if wage[1] < money: print(wage[0] + '的工资是' + str(wage[1]) + '人民币,不足以支付订单...') print('|| 支付 ||'.center(115)) print('=' * 130) print('充值金钱'.center(20),end='\t') print('查看余额'.center(65),end='\t') print('放弃支付'.center(45),end='\t') print('\n') print('=' * 130) shop_k = input('请输入你要选择的功能<<<') if shop_k == '充值金钱': age = input('请输入你要充值的金钱<<<') wage[1] = wage[1] + int(age) print('恭喜你,充值成功!') if shop_k == '查看余额': print(wage[0] + '的余额是' + str(wage[1]) + '人民币') if shop_k == '放弃支付': break if wage[1] > money : wage[1] = wage[1] - money print('订单提交成功!'+wage[0]+',您的余额还有'+str(wage[1])+'人民币') sprice.clear() break
#列表信息lisl = ['deng','123','taibai','123456','alex','2019','Jing','2017']sprice = []#遍历商品mess = [] # 列表,存上一级菜单def message(): # 商品信息 shopping = { '首页': {'天猫新品': { 'marmot保暖鹅绒':2219, '丝飘本色卷纸':9, 'marmot男士长袖':229 }, '今日爆款': { '拉菲珍藏波尔多6支':359, '美心流心奶黄月饼礼盒':348, '乳酸菌饮品340ml*12瓶整箱':16 }, '天猫超市': { '蓝月亮洁净洗衣液':9, '好想你免洗灰枣':9, '友臣福建特产肉松饼':29 }, '飞猪旅行': { '哈尔滨接机服务':30, '芽庄泥浆浴一日游':58, '张家界大峡谷门票':208 } },
'母婴': {'毛绒玩具': { '冰丝抱枕北极熊':268, '猫咪陪你睡觉抱枕':69, '可爱仓鼠小老鼠睡觉抱枕':29 }, '儿童运动鞋': { 'NIKE':1000, 'Adidas':800, '乔丹':100 }, '益智玩具': { '魔方':30, '变形金刚':200, '探索者':30000 } },
'百货': {'低价清仓': { }, '水杯': { '马克杯':18, '玻璃杯':5, '保温杯':60 }, '拖鞋': { '夏季拖鞋':20, '冬季拖鞋':50 }, '颈枕': { 'u型枕':79, '记忆枕':245 } },
'运动': {'跑鞋': { 'NIKE': 1000, 'Adidas': 800, '乔丹': 100 }, '自行车': { '凤凰自行车':700, '上海永久':500 }, '球鞋': { 'NIKE': 1000, 'Adidas': 800, '乔丹': 100 } }
} while 1 : print('商品信息'.center(110)) print('~' * 130) for i in shopping: print(i.center(110)) print('~' * 130) choice = input('请输入你要访问的商品') if choice in shopping: if type(shopping[choice]) is int : print('是否购买该商品,如果购买输入Y,否则输入b返回上一级菜单') pp1 = input('<<<') if pp1.upper() == 'Y': for tom in range(len(sprice)): if choice in sprice[tom][0]: sprice[tom][2] = sprice[tom][2] + 1 break # 每一次的信息变成列表形式 space = [] space.append(choice) space.append(shopping[choice]) space.append(1) sprice.append(space) print('购买成功,已添加购物车!') while len(sprice) > 1 : if sprice[-1][0] in sprice[0:-1][0]: del sprice[-1] else: break else: mess.append(shopping) shopping = shopping[choice] if choice == 'e': break if choice == 'b': shopping = mess[-1] del mess[-1]
#main0方法 #购物模块def main0 (): while 1: tao_first() t5 = input('你输入你要选择的功能<<<') if t5 == '注册': enter() elif t5 == '登陆': login() break elif t5 == '退出': exit() message()
money = 0 # 金钱【账单总值】wage = [] #工资#main1方法def main1(): global money while 1: tao_second() ma1 = input('你选择服务<<<') if ma1== '提交订单': for i in range(len(sprice)): money = sprice[i][1] * sprice[i][2] second2 = '|| 购物车订单 ||'.center(125) print(second2) print() print('=' * 130) print('商品名称', end='\t') print('价格', end='\t') print('数量', end='\t') print('\n') for i in sprice: print(i) print('-' * 130) print('您本次需要支付'+str(money)+'人民币') staff_wage()
if ma1 == '删除订单': add_mal2 = input('请输入你要删除的商品名称:') add_mal3 = input('请输入你要删除该商品名称的个数:') for tom in range(len(sprice)): if add_mal2 in sprice[tom][0]: if int(add_mal3) >= sprice[tom][2] : del sprice[tom] else: sprice[tom][2] = sprice[tom][2] - int(add_mal3) if ma1 == '添加订单': add_mal0 = input('请输入你要添加的商品名称:') add_mal1 = input('请输入你要添加该商品名称的个数:') for tom in range(len(sprice)): if add_mal0 in sprice[tom][0]: sprice[tom][2] = sprice[tom][2] + int(add_mal1) print('订单添加成功!') if ma1 == '查看订单': second1 = '|| 购物车订单 ||'.center(125) print(second1) print() print('=' * 130) print('商品名称', end='\t') print('价格', end='\t') print('数量', end='\t') print('\n') for i in sprice: print(i) print('-' * 130) if ma1 == '继续购物': message()
if ma1 == '退出系统': exit()
#main方法def main(): main0() main1()main()
淘淘购物系统 (Python)的更多相关文章
- 绝对好评的淘宝购物导航:baiso.uz.taobao.com
绝对好评的淘宝购物导航:baiso.uz.taobao.com 绝对好评的淘宝购物导航--百搜:http://baiso.uz.taobao.com
- python 操作mysql数据库之模拟购物系统登录及购物
python 操作mysql数据库之模拟购物系统登录及购物,功能包含普通用户.管理员登录,查看商品.购买商品.添加商品,用户充值等. mysql 数据库shop 表结构创建如下: create TAB ...
- JAVAEE——淘淘商城第一天:电商行业的背景和技术特点,商城的介绍、技术的选型、系统架构和工程搭建
1. 学习计划 1.电商行业的背景. 2.电商行业的技术特点 3.商城的介绍 a) 常用的名词介绍 b) 系统功能介绍 4.淘淘商城的系统架构 a) 传统架构 b) 分布式架构 c) 基于服务的架构 ...
- day78_淘淘商城项目_11_单点登录系统实现 + 用户名回显 + ajax请求跨域问题详解_匠心笔记
课程计划 1.SSO注册功能实现 2.SSO登录功能实现 3.通过token获得用户信息 4.ajax跨域请求解决方案--jsonp 1.服务接口实现 SSO系统就是解决分布式环境下登录问题的,本 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十二天】(系统架构讲解、nginx)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- 第04项目:淘淘商城(SpringMVC+Spring+Mybatis)【第十天】(单点登录系统实现)
https://pan.baidu.com/s/1bptYGAb#list/path=%2F&parentPath=%2Fsharelink389619878-229862621083040 ...
- [ python ] 购物系统
作业需求 1. 购物系统,能够注册登录,用户第一次登录后,让用户输入金额,然后打印商品列表2. 允许用户根据商品编号购买商品3. 用户选择商品后,检测余额是否够,够就直接扣款,不够就提醒4. 购买完一 ...
- 淘淘商城_day11_课堂笔记
今日大纲 发布前的准备 实施发布 一部分是由我来发布 一部分是由你们来发布 讲解分布式部署架构 测试 功能测试 压力测试 项目实战的准备以及分组 分组 抽取功能 讲解所需要开发的功能 项目部署上线流程 ...
- 淘淘商城_day04_课堂笔记
今日大纲 实现首页的大广告位功能 实现内容管理系统 首页的大广告 什么是大广告 JS效果: 点击下面的序号选择查询哪个广告 自动切换 点击图片查询具体的页面 以上是由前端团队来开发. 数据结构 说明: ...
随机推荐
- Tomcat+MySQL常见调优参数
一.Tomcat 调优 (一).Tomcat内存优化 参数一: vim /tomcat/bin/catalina.sh CATALINA_OPTS="-server -Xms128m -Xm ...
- Unity经典游戏教程之:雪人兄弟
版权声明: 本文原创发布于博客园"优梦创客"的博客空间(网址:http://www.cnblogs.com/raymondking123/)以及微信公众号"优梦创客&qu ...
- Docker笔记(七):常用服务安装——Nginx、MySql、Redis
开发中经常需要安装一些常用的服务软件,如Nginx.MySql.Redis等,如果按照普通的安装方法,一般都相对比较繁琐 —— 要经过下载软件或源码包,编译安装,配置,启动等步骤,使用 Docker ...
- 4如何用PHP给MySQL数据库添加记录
首先连接数据库(依旧用第二篇的方法) 假设数据库表里只有id,name,email三列 添加以下代码 $inputemail=写你要的email;$inputname=写你要的name;//先设定你要 ...
- 5、数组的复制(test2.java、test3.java)
对于数组的复制,在最开始的时候最容易犯的一个错误,那就是自己认为的申请一个数组,然后将已存在的数组赋值到新申请数组名上,这样是错误的,这样仅仅是将数组的地址复制了过去,并不是,将数组内的元素拷贝过去, ...
- Starling 环形进度条实现
项目初期想实现这个效果来着,查了很多资料(包括式神的<神奇的滤镜>),也没找到完美的实现方法,,当时时间紧迫,就找了传统的进度条来代替实现. 最近偶然心血来潮,查了各方面资料,终于找到实现 ...
- CentOS yum 源修改
修改 CentOS 默认 yum 源为 mirrors.163.com 首先备份系统自带yum源配置文件/etc/yum.repos.d/CentOS-Base.repo [root@localhos ...
- web面试
什么是面向对象? 程序中的事物都是用对象结构来描述的,所有的程序都是用面向对象的思想,管理数据和功能的. 面向对象三大特点:封装 继承 多态 什么是封装? 创建一个对象结构,用来保存一个事物的属性和方 ...
- intellij idea与github整合管理代码
各位看官大家好,博主每每在公司学习新知识写代码时都需要通过U盘带回家来继续每天的学习,觉得这样实在麻烦,于是今天就整合了一下github来完成代码的管理. 开始之前我们需要准备三样东西:1.intel ...
- 峰回路转:去掉 DbContextPool 后 Windows 上的 .NET Core 版博客表现出色
今天早上,我们修改了博客程序中的1行代码,将 services.AddDbContextPool 改为 services.AddDbContext ,去掉 DbContextPool . 然后奇迹出现 ...