python---购物车
来源:互联网 发布:参加java培训班有用吗 编辑:程序博客网 时间:2024/06/05 21:52
实现购物车:#!/usr/bin/env python#coding:utf-8__author__ = "lvah"'''@author:wangjiazhuo@file:购物车.py@contact:pucca@163.com@time:7/12/176:23 PM@desc:'''salary = raw_input('input your salary:')if salary.isdigit(): salary = int(salary)shop_car = []mall = [ ('Ipone',8000), ('Book',200), ('Bike',1000)]for item in enumerate(mall): num = item[0] name = item[1][0] price = item[1][1] print num, name, pricewhile True: choice = raw_input('choose you want to buy: q to exit') if choice.isdigit(): choice = int(choice) if choice <= len(mall)-1: p_item = mall[choice] if salary < p_item[1]: print '余额不足,请购买其他商品或退出' elif salary > 0: shop_car.append(p_item) salary -= p_item[1] print '\n你买到的商品有:', for item in shop_car: print item print '你的余额为:%d'%salary else: pass else: print '请输入已有的商品编号' elif choice == 'q': print '\n你买到的商品有:' for item in shop_car: print item print '你的余额为:%d'%salary exit(0) else: print '请重新选择'
执行结果:
阅读全文
0 0
- python练习:购物车
- python练习-购物车
- Python-购物车
- python购物车
- python---购物车
- python--购物车
- python 购物车菜单
- Python--购物车
- python-----购物车
- python的购物车实例
- python基础学习--购物车小程序
- python实现简单的购物车
- python写的购物车小程序
- python练习题:实现购物车功能
- Python购物车系统模拟1
- Python笔记(三)购物车小程序
- Python Django实现简单购物车功能
- Python程序练习3--模拟购物车
- heroku command
- transform-origin学习笔记之旋转与基点的关系
- 18位身份证号码校验
- int const 与 const int区别 以及指针相关
- cocoapods安装与使用
- python---购物车
- caffe的solver的参数的含义和设置
- Python中字段抽取、字段拆分、记录抽取
- C++ 数组
- Spring框架HelloWorld程序
- 大型网站架构概述
- Qt学生信息管理系统
- 计算机网络肢解计划之篇一:网络体系结构
- 2017.7.13