首页 > 代码库 > python--购物车
python--购物车
#!/usr/bin/env python #coding:utf-8 __author__ = "mmm" ‘‘‘ @author:sum @file:shopping car.py @time:7/12/1710:48 PM @desc ‘‘‘ iphone = 0 book = 0 bike = 0 money = input("请输入账户金额:") list = {(‘iphone‘,8000), (‘book‘,100), (‘bike‘,200)} for i in enumerate(list): a = i[0] b = i[1][0] c = i[1][1] print a,b,c while True: num = raw_input("请输入商品序号:") if num == ‘0‘: if money > 200: money = money-200 bike = bike +1 print ‘账户余额%s‘ %money else: print ‘余额不足‘ if num == ‘1‘: if money > 100: money = money -100 book = book +1 print ‘账户余额%s‘ %money else: print ‘余额不足‘ if num == ‘2‘: if money > 8000: money = money -8000 iphone = iphone +1 print ‘账户余额%s‘%money else: print ‘余额不足‘ if num == ‘quit‘: print ‘购买清单 iphone %s \n book %s\n bike %s\n‘ %(iphone,book,bike) print ‘账户余额 %s‘ %money break
python--购物车
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。