目录

  • 问题详情
  • 源代码

问题详情

请点击此处跳转

源代码

import pymysql
conn = pymysql.connect(host = '127.0.0.1',user = 'root',password = 'root',database = 'fruitshopdb')
cur=conn.cursor()
while(True):print("----------------------------")print("1.查询全部水果")print("2.查询指定名称的水果")print("3.增加水果")print("4.修改水果的数量")print("5.删除水果")print("6.按照价格排序")print("7.添加水果的种类")print("8.显示商品的品牌")print("0.退出系统")print("----------------------------")num_data=input('请输入对应的功能序号:')# 1.查询全部水果if num_data=='1':sql = 'select * from fruit;'cur.execute(sql)data=cur.fetchall()print(data)continue# 2.查询指定名称的水果elif num_data=='2':find_name = input('请输入查询水果水果的名字:')sql = 'select * from fruit where fName="%s"'%(find_name)cur.execute(sql)data = cur.fetchall()print(data)continue# 3.增加水果elif num_data=='3':new_fName = input('请输入你要添加的水果的名字:')new_price = int(input('请输入你要添加的水果的价格:'))new_fruitNumble = int(input('请输入你新添加的水果的数量:'))new_band = input('请输入你要添加的水果的品牌:')sql='insert into fruit(fname,price,fruitNumble,band)values("%s",%d,%d,"%s")'%(new_fName,new_price,new_fruitNumble,new_band)cur.execute(sql)conn.commit()sql2='select * from fruit where fName="%s"'%(new_fName)cur.execute(sql2)data = cur.fetchall()print('成功添加的水果:',data)continue# 4.修改水果的数量elif num_data=='4':fid=int(input('请输入需更新水果的id:'))updateNumble=int(input('请输入你要更新水果的数量:'))sql='update fruit set fruitNumble=%d where fid=%d'%(updateNumble,fid)cur.execute(sql)conn.commit()sql2='select * from fruit where fid="%s"'%(fid)cur.execute(sql2)data = cur.fetchall()print('成功修改水果的数量:',data)continue# 5.删除水果elif num_data=='5':fid=input('请输入你要删除的水果id:')sql='delete from fruit where fid="%s"'%(fid)cur.execute(sql)conn.commit()sql1 = 'select * from fruit;'cur.execute(sql1)for i in cur.fetchall():print(i)continue# 6.按照价格排序elif num_data=='6':print('商品的价格升序排列:')print('价格  水果名   品牌')sql='select price,fname,band from fruit order by price asc'cur.execute(sql)for i in cur.fetchall():print(i)continue# 7.添加水果的种类elif num_data=='7':new_fName = input('请输入你要添加的水果的名字:')new_price = int(input('请输入你要添加的水果的价格:'))new_fruitNumble = int(input('请输入你新添加的水果的数量:'))new_band = input('请输入你要添加的水果的品牌:')sql='insert into fruit(fname,price,fruitNumble,band)values("%s",%d,%d,"%s")'%(new_fName,new_price,new_fruitNumble,new_band)cur.execute(sql)conn.commit()sql1 = 'select * from fruit;'cur.execute(sql1)for i in cur.fetchall():print(i)continue# 8.显示商品的品牌elif num_data=='8':print('商品的品牌:')sql='select band from fruit'cur.execute(sql)for i in cur.fetchall():print(i)continueelse:quit=input('你是否要退出系统!YES or NO???')if quit=='YES':breakelif quit=='NO':num_data()else:print('输入错误!')
cur.close()
conn.close()
print('你已成功退出系统!')

python面向过程之水果超市相关推荐

  1. python面向对象之水果超市

    目录 项目要求 分析问题,把概念模型转化为E-R图 运行结果 查询全部水果 查询指定名称水果 增加水果 修改水果的数量 删除水果 按照价格排序 添加水果的种类 显示商品的品牌 退出系统 python源 ...

  2. Python tkinter 做水果超市!

    今天教大家做python tkinter 弹窗水果超市 , 非常好用 ! import tkinter as tk from tkinter import ttk win = tk.Tk() win[ ...

  3. python水果超市管理系统_java实现水果超市管理系统

    本文为大家分享了java实现水果超市管理系统的具体代码,供大家参考,具体内容如下 首先建立水果类的界面 public class Fruit { //定义ID private String id; / ...

  4. python水果超市管理系统_项目1-水果超市管理系统-学生

    华中农业大学理学院计算机科学系 2011 级 -- C/C++ 语言程序设计( 2 ) 2012 年 2 月 1 友情提示:部分程序功能及相关内容要求等,会在后续进行 适当调整,敬请关注每次实验最后一 ...

  5. python水果超市项目_水果超市经营模式,实现营业额翻3倍,年纯利超24万的经营干货...

    现在几乎每一个小区附近都会有很多的水果店,开一家水果店的成本都差不多,但是为什么盈利状况差别巨大呢?同样位置的店铺关门转让,后来者同样做水果却能蒸蒸日上?这里面的关键差异就在于水果超市经营模式和技巧上 ...

  6. python面向对象案例--买水果

    python面向对象案例–买水果 知识点讲解 面向对象基础 ​ 我今天讲的用一句话概括就是对象是可以被当做参数传递的,这句话很精髓 ​ 在你看到这篇文章时,你至少要了解,对象,类,方法,属性这些概念 ...

  7. [附源码]Java计算机毕业设计SSM白果园网上水果超市

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  8. [附源码]JAVA+ssm计算机毕业设计白果园网上水果超市(程序+Lw)

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  9. Python培训教程之Python基础知识点梳理

    Python语言是入门IT行业比较快速且简单的一门编程语言,学习Python语言不仅有着非常大的发展空间,还可以有一个非常好的工作,下面小编就来给大家分享一篇Python培训教程之Python基础知识 ...

最新文章

  1. 泛型推断类型不符合上限
  2. Emoji表情符号录入MySQL数据库报错的解决方案
  3. 好程序员web前端分享数组及排序、去重和随机点名
  4. Python基础(偏函数)
  5. Spring Boot——易班优课YOOC课群在线测试自动答题解决方案(六)后端改造
  6. Android无线调试出现错误的解决方法
  7. python管理工具ports_Python options.port方法代码示例
  8. 【Pytorch神经网络理论篇】 37 常用文本处理工具:spaCy库+torchtext库
  9. 网易云音乐电脑版怎么下载电台节目 主播电台节目下载教程
  10. 'display','position'和'float'相互关系
  11. 使用函数输出水仙花数
  12. Mysql学习总结(51)——Linux主机Mysql数据库自动备份
  13. pythoncookbook和流畅的python对比_为什么你学Python效率比别人慢?因为你没有这套完整的学习资料...
  14. 谷歌EfficientNet缩放模型,PyTorch实现出炉,登上GitHub热榜丨Demo可用
  15. 《Unix环境高级编程》学习之Unix标准
  16. 网页木马是什么原理?
  17. 免费送纸质书, 感谢亲们的陪伴~
  18. 微信小程序----全局状态管理 (便于全局埋点等操作)
  19. PHP+Mysql 实现留言板
  20. 怎么用python画房子_用python画一个小房子

热门文章

  1. 岭回归原理简单分析与理解
  2. 管理学原理 【1049】
  3. 无线密码破解工具 - Aircrack-ng
  4. ImportError: (‘You must install pydot (`pip install pydot`) and install grap
  5. RecyclerView 嵌套RecyclerView 或者 ScrollView当中嵌套RecyclerView ,子View会自动滚动到顶部
  6. 如何修改Kestrel上传文件的大小
  7. sja1000 中断_SJA1000中断接收为什么接收中断不能被触发,不能进入中断接收子函数?看资料,里面说会自动触发中断的。...
  8. 大学物理复习-静电场
  9. 将表格导出为excel
  10. JUST技术:从GPS数据中挖掘用户行为习惯