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 相关文章推荐
在Django中使用Sitemap的方法讲解
Jul 22 Python
Python使用三种方法实现PCA算法
Dec 12 Python
django静态文件加载的方法
May 20 Python
Django csrf 验证问题的实现
Oct 09 Python
python学生信息管理系统(完整版)
Apr 05 Python
Python OpenCV调用摄像头检测人脸并截图
Aug 20 Python
django自带serializers序列化返回指定字段的方法
Aug 21 Python
face++与python实现人脸识别签到(考勤)功能
Aug 28 Python
python GUI库图形界面开发之PyQt5切换按钮控件QPushButton详细使用方法与实例
Feb 28 Python
Python如何实现FTP功能
May 28 Python
如何用python绘制雷达图
Apr 24 Python
python实现会员信息管理系统(List)
Mar 18 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
PHP漏洞全解(详细介绍)
2012/11/13 PHP
php表单提交与$_POST实例分析
2015/01/26 PHP
求帮忙修改个php curl模拟post请求内容后并下载文件的解决思路
2015/09/20 PHP
php如何利用pecl安装mongodb扩展详解
2019/01/09 PHP
Cookie 小记
2010/04/01 Javascript
jquery事件与函数的使用介绍
2013/09/29 Javascript
js验证输入是否为手机号码或电话号码示例
2013/12/30 Javascript
jquery的ajax跨域请求原理和示例
2014/05/08 Javascript
jQuery实现提交按钮点击后变成正在处理字样并禁止点击的方法
2015/03/24 Javascript
利用Vue.js指令实现全选功能
2016/09/08 Javascript
Bootstrap学习笔记之环境配置(1)
2016/12/07 Javascript
用 js 的 selection range 操作选择区域内容和图片
2017/04/18 Javascript
详解为Bootstrap Modal添加拖拽的方法
2018/01/05 Javascript
详解vue-cli 2.0配置文件(小结)
2019/01/14 Javascript
微信小程序生成海报分享朋友圈的实现方法
2019/05/06 Javascript
[03:39]DOTA2英雄梦之声_第05期_幽鬼
2014/06/23 DOTA
[01:13:08]2018DOTA2亚洲邀请赛4.6 淘汰赛 mineski vs LGD 第二场
2018/04/10 DOTA
Python线程的两种编程方式
2015/04/14 Python
Python使用Mechanize模块编写爬虫的要点解析
2016/03/31 Python
Python语言描述随机梯度下降法
2018/01/04 Python
深入浅析Python传值与传址
2018/07/10 Python
Python3.7 dataclass使用指南小结
2019/02/22 Python
Django中使用session保持用户登陆连接的例子
2019/08/06 Python
python 利用pyttsx3文字转语音过程详解
2019/09/25 Python
matplotlib绘制多个子图(subplot)的方法
2019/12/03 Python
jupyter lab文件导出/下载方式
2020/04/22 Python
css3 中实现炫酷的loading效果
2019/04/26 HTML / CSS
如何进行有效的自我评价
2013/09/27 职场文书
办公室文员工作职责
2014/01/31 职场文书
婚庆司仪主持词
2014/03/15 职场文书
假期安全教育广播稿
2014/10/04 职场文书
小学生通知书评语
2014/12/31 职场文书
结婚喜宴祝酒词
2015/08/10 职场文书
解决mysql:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO/YES)
2021/06/26 MySQL
解析目标检测之IoU
2021/06/26 Python
Win11怎么跳过联网验机 ?Win11跳过联网验机激活教程
2022/04/05 数码科技