python shopping incomplete code
#shopping code
#shopping.py
#导入登录模块
import login
# shop car beginning
salary = input("请输入工资:\t")
###判断输入工资是否为整型###
if salary.isdigit():
salary = int(salary)
else:
print ("salary not digit")
exit()
###打印一句牛逼的话####
welcome_msg = 'welcome to our shoping mall'
print(welcome_msg.center(50, '-'))
###商品列表####
shopcar = [
('Iphone', 5888),
('Mac Air', 8000),
('XiaoMi', 19.9),
('coffee', 30),
('Tesla', 8200),
('Bike', 700),
('Cloth', 200)
]
for i in enumerate(shopcar):
index = i[0]
product = i[1][0]
p_salary = i[1][1] print (index, product, p_salary) exit_msg = '你可以输入e或者q退出,啦啦啦'
print(exit_msg.center(50, '-')) while True:
num = input("\033[5;30;43mplease print bianhao:\033[0m\t")
if num.isdigit():
num = int(num)
###判断输入编号不能大于7###
if num > 7:
print ("输入错误,没有此编号")
continue
##输入编号购买商品###
num = input("请输入商品编号:\t")
price = shopcar[num][1]
price_p = shopcar[num][0]
if salary > price:
salary -= price
print ("购买成功,余额为", salary)
print ("购买的商品为:", price_p)
else:
print ("余额不足,请及时充值")
print ("余额为", salary)
continue
##exit shoping##
elif num.isalpha():
num = str(num)
if num == 'e' or num == 'q':
print ("余额为", salary)
bye_msg = 'next to meet you,see you'
print(bye_msg.center(50, '-'))
break
# if price_p():
# print ("余额为", salary)
# exit()
# else:
# print ("购买成功,余额为", salary)
# print ("购买的商品为:", price_p)
# bye_msg = 'next to meet you,see you'
# print(bye_msg.center(50, '-'))
python shopping incomplete code的更多相关文章
- Converting Python Virtual Machine Code to C
Converting Python Virtual Machine Code to C
- Python on VS Code
install python extension Press F1, and input "ext install python". Then the icon at the le ...
- python 调用 C++ code
本文以实例code讲解python 调用 C++的方法. 1. 如果没有参数传递从python传递至C++,python调用C++的最简单方法是将函数声明为C可用函数,然后作为C code被pytho ...
- Python “ValueError: incomplete format” print(“a%” % ”)
解决python打印%号和%format输出问题 >>> print('%s' %'1') 1 >>> print('%s%' %'1') Traceback (m ...
- Pycharm创建Django项目显示python non-zero exit code(1)错误
好久时间没有做Django的项目了,今天创建项目竟然报Non-zero exit code(1)错误 查明原因是因为pip不是最新版本,需要执行以下命令:python -m pip install - ...
- python en(de)code
python爬虫 代码写挺长的,也是边学边写,但一直搞不清楚python的encode(编码)和decode(解码).以下是我的探究之路. 一.当然先看官方文档 地址如下 里面提到encode函数'R ...
- python单线程爬虫code
广度优先算法: # -*- coding: utf-8 -*- import urllib import urllib.request from bs4 import BeautifulSoup im ...
- python——shopping car
# _Author:huang# date: 2017/11/26 # 简单的购物车程序money = input("money:") product_list = [ (&quo ...
- facebook视频上传python 返回错误code:100,'type':OAuthException
首先重新获取访问口令token: https://developers.facebook.com/tools/debug/accesstoken/?q=EAAYDuzyd3eYBAK9lZCErZBl ...
随机推荐
- 使用chart.js時取消懸浮在圖表頂部的'undefined'標識
解決方法:在options中設置legend項中display屬性為false options: { scales: { yAxes: [{ ticks: { beginAtZero: true } ...
- 正则基础之——NFA引擎匹配原理
记录一下一篇很好的博文:https://blog.csdn.net/lxcnn/article/details/4304651
- SpringBoot1.5.2安装配置--1.5.2版本问题
简述下java环境 1.安装jdk http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm ...
- 遇到Caused by: java.lang.NoClassDefFoundError: javax/validation/ParameterNameProvider
今天在做spring和hibernate整合的时候遇到这个问题 网上搜找到这里有解决办法 http://blog.csdn.net/jueshengtianya/article/details/122 ...
- git学习笔记5
查看保存的进度 git stash list 恢复进度 git stash pop 测试运行哪些文件会被删除 git clean -nd 强制删除 git clean -fd 保存当前的工作进度,会保 ...
- html中超链接的target属性
<a> 标签的 target 属性规定在何处打开链接文档.(target就是目标的意思) 一共有(4+1种选择): 用法:<a target="value"> ...
- git 自己创建了一个项目A,我的同事fork一个B,当我的项目更新的时候,怎么样在他fork的repo上进行相应的更新?
先把B clone到本地 git clone B_REPOSITORY_URL 再cd到本地B的目录,把A作为一个remote加到本地的B中(一般命名为upstream) git remote add ...
- DBUtils工具类的使用
DBUtils工具类1.DBUtils工具类,由apache组织提供的工具类,对JDBC做了一些简单封装. 做了查询的封装,把查询的结果封装到List集合 Map集合 JavaBean对象中 做了增删 ...
- step5: 编写spider爬取
改写parse函数 实现功能: 1.获取文章列表页中的文章url并交给scrapy下载后,交给解析函数进行具体字段的解析2.获取下一页的url并交给scrapy进行下载,下载完成后交给parse 提取 ...
- [转]微信小程序开发:http请求
本文转自:http://www.cnblogs.com/dragondean/p/5921079.html 在微信小程序进行网络通信,只能和指定的域名进行通信,微信小程序包括四种类型的网络请求. 普通 ...