python实现学生信息管理系统源码


Posted in Python onFebruary 22, 2021

本文实例为大家分享了python实现学生信息管理系统的具体代码,供大家参考,具体内容如下

代码如下:

Project.py文件内容:

class Student(object):
 # 建立学生信息储存的列表(嵌套的方式)
 studentInformation = []
 # 对学生对象的数据进行说明
 studentShow = ["学号:", "姓名:", "年龄:"]

 # 录入学生
 def addstudent(self):
  sno = input("请输入学号:")
  name = input("请输入姓名:")
  sage = input("请输入年龄:")
  # 建立一个列表,用于暂时存储
  student = [sno, name, sage]
  # 加入学生(判断学号是否重复)
  x = 0
  # 刚开始录入学生时,学号不可能重复
  if len(self.studentInformation) == 0:
   self.studentInformation.append(student)
  # 判断重复
  else:
   while x < len(self.studentInformation):
    if self.studentInformation[x][0] != sno:
     x += 1
    else:
     print("学号重复!!!\n请重新输入序号!!!")
     break
   else:
    self.studentInformation.append(student)
    print("加入成功!!!")

 # 输出学生
 def showstudent(self):
  print("学生信息输出如下:")
  for i in range(len(self.studentInformation)):
   print(self.studentShow[0]+self.studentInformation[i][0], end=" ")
   print(self.studentShow[1] + self.studentInformation[i][1], end=" ")
   print(self.studentShow[2] + self.studentInformation[i][2])

 # 删除学生
 def deletestudent(self):
  x = 0
  sno = input("请输入学生学号:")
  while x < len(self.studentInformation):
   if self.studentInformation[x][0] == sno:
    del self.studentInformation[x]
    print("删除学生成功!!!")
    break
   else:
    x += 1
  else:
   print("不存在当前学生!!!")

 # 查询学生
 def selectstudent(self):
  x = 0
  sno = input("请输入查询学生的学号")
  while x < len(self.studentInformation):
   if self.studentInformation[x][0] == sno:
    print(self.studentShow[0] + self.studentInformation[x][0], end=" ")
    print(self.studentShow[1] + self.studentInformation[x][1], end=" ")
    print(self.studentShow[2] + self.studentInformation[x][2])
    break
   else:
    x += 1
  else:
   print("未查询到当前学生!!!")

 # 修改学生
 def changestudent(self):
  x = 0
  sno = input("请输入修改学生的学号:")
  while x < len(self.studentInformation):
   if self.studentInformation[x][0] == sno:
    name = input("请输入修改后的姓名:")
    sage = input("请输入修改后的年龄:")
    self.studentInformation[x][1] = name
    self.studentInformation[x][2] = sage
    print("修改成功!!!")
    break
   else:
    x += 1

 # 界面打印
 @staticmethod
 def printui():
  print("输入:0 --退出程序--")
  print("输入:1 --录入学生--")
  print("输入:2 --输出学生--")
  print("输入:3 --删除学生--")
  print("输入:4 --查询学生--")
  print("输入:5 --修改学生--")

 # 程序调用
 def run(self):
  self.printui()
  number = input("请输入功能前面的代码:")
  # 无限循环
  var = 1
  while var == 1:
   if int(number) == 1:
    self.addstudent()
    self.printui()
    number = input("请输入功能前面的代码:")
   elif int(number) == 2:
    self.showstudent()
    self.printui()
    number = input("请输入功能前面的代码:")
   elif int(number) == 3:
    self.deletestudent()
    self.printui()
    number = input("请输入功能前面的代码:")
   elif int(number) == 4:
    self.selectstudent()
    self.printui()
    number = input("请输入功能前面的代码:")
   elif int(number) == 5:
    self.changestudent()
    self.printui()
    number = input("请输入功能前面的代码:")
   elif int(number) == 0:
    break
   else:
    print("您输入的序号不对!\n请重新输入!")
    self.printui()
    number = input("请输入功能前面的代码:")
  else:
   print("再见!")
   exit()

text.py文件:

from Project import Student
# 实例化对象
stu = Student()
stu.run()

运行结果:

python实现学生信息管理系统源码

python实现学生信息管理系统源码

python实现学生信息管理系统源码

python实现学生信息管理系统源码

python实现学生信息管理系统源码

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持三水点靠木。

Python 相关文章推荐
Python列表计数及插入实例
Dec 17 Python
Python输出9*9乘法表的方法
May 25 Python
PYTHON压平嵌套列表的简单实现
Jun 08 Python
Python跨文件全局变量的实现方法示例
Dec 10 Python
用TensorFlow实现多类支持向量机的示例代码
Apr 28 Python
python3实现字符串的全排列的方法(无重复字符)
Jul 07 Python
python计算Content-MD5并获取文件的Content-MD5值方式
Apr 03 Python
Scrapy爬虫文件批量运行的实现
Sep 30 Python
解决使用Pandas 读取超过65536行的Excel文件问题
Nov 10 Python
Python监听剪切板实现方法代码实例
Nov 11 Python
使用Python+OpenCV进行卡类型及16位卡号数字的OCR功能
Aug 30 Python
Python中使用Opencv开发停车位计数器功能
Apr 04 Python
python实现简单的学生管理系统
Feb 22 #Python
matplotlib之pyplot模块坐标轴标签设置使用(xlabel()、ylabel())
Feb 22 #Python
matplotlib之pyplot模块之标题(title()和suptitle())
Feb 22 #Python
matplotlib源码解析标题实现(窗口标题,标题,子图标题不同之间的差异)
Feb 22 #Python
python利用后缀表达式实现计算器功能
Feb 22 #Python
Python使用tkinter实现小时钟效果
Feb 22 #Python
Python tkinter实现日期选择器
Feb 22 #Python
You might like
Snoopy类使用小例子
2008/04/15 PHP
php实现快速排序的三种方法分享
2014/03/12 PHP
PHP SOCKET编程详解
2015/05/22 PHP
php项目开发中用到的快速排序算法分析
2016/06/25 PHP
PHP执行普通shell命令流程解析
2020/08/24 PHP
JavaScript 闭包深入理解(closure)
2009/05/27 Javascript
Whatever:hover 无需javascript让IE支持丰富伪类
2010/06/29 Javascript
JavaScript定义类的几种方式总结
2014/01/06 Javascript
JQUERY实现网页右下角固定位置展开关闭特效的方法
2015/07/27 Javascript
整理Javascript基础入门学习笔记
2015/11/29 Javascript
jQuery实现HTML表格单元格的合并功能
2016/04/06 Javascript
基于jquery实现最简单的选项卡切换效果
2016/05/08 Javascript
Vue.js双向绑定操作技巧(初级入门)
2016/12/27 Javascript
基于JS实现翻书效果的页面切换样式
2017/02/16 Javascript
Vue+axios 实现http拦截及路由拦截实例
2017/04/25 Javascript
详解Vue整合axios的实例代码
2017/06/21 Javascript
nodejs acl的用户权限管理详解
2018/03/14 NodeJs
解决在Bootstrap模糊框中使用WebUploader的问题
2018/03/22 Javascript
vue封装一个简单的div框选时间的组件的方法
2019/01/06 Javascript
微信小程序缓存支持二次开发封装实现解析
2019/12/16 Javascript
[13:39]2014 DOTA2华西杯精英邀请赛 5 25 NewBee VS DK第一场
2014/05/26 DOTA
[33:42]LGD vs OG 2018国际邀请赛小组赛BO2 第一场 8.16
2018/08/17 DOTA
让python json encode datetime类型
2010/12/28 Python
python 类对象和实例对象动态添加方法(分享)
2017/12/31 Python
Django外键(ForeignKey)操作以及related_name的作用详解
2019/07/29 Python
如何基于windows实现python定时爬虫
2020/05/01 Python
python cv2.resize函数high和width注意事项说明
2020/07/05 Python
基于python实现生成指定大小txt文档
2020/07/20 Python
python绘制雷达图实例讲解
2021/01/03 Python
LightInTheBox法国站:中国跨境电商
2020/03/05 全球购物
我的大学生活职业生涯规划
2014/01/02 职场文书
移风易俗倡议书
2014/04/15 职场文书
2014国庆节幼儿园亲子活动方案
2014/09/16 职场文书
2015医德医风个人工作总结
2015/04/02 职场文书
关于运动会的广播稿
2015/08/19 职场文书
go语言map与string的相互转换的实现
2021/04/07 Golang