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中的zip函数使用示例
Jan 29 Python
快速了解python leveldb
Jan 18 Python
Python工厂函数用法实例分析
May 14 Python
python模块smtplib学习
May 22 Python
django1.11.1 models 数据库同步方法
May 30 Python
Python中list查询及所需时间计算操作示例
Jun 21 Python
Python实现滑动平均(Moving Average)的例子
Aug 24 Python
pycharm激活码有效到2020年11月底
Sep 18 Python
浅析pip安装第三方库及pycharm中导入第三方库的问题
Mar 10 Python
Matplotlib animation模块实现动态图
Feb 25 Python
python OpenCV学习笔记
Mar 31 Python
Python OpenCV之常用滤波器使用详解
Apr 07 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使用array_multisort对多个数组或多维数组进行排序
2014/12/16 PHP
PHP微信API接口类
2016/08/22 PHP
Yii2学习笔记之汉化yii设置表单的描述(属性标签attributeLabels)
2017/02/07 PHP
4种Windows系统下Laravel框架的开发环境安装及部署方法详解
2020/04/06 PHP
Nodejs为什么选择javascript为载体语言
2015/01/13 NodeJs
js中判断变量类型函数typeof的用法总结
2016/08/09 Javascript
Angular中使用ui router实现系统权限控制及开发遇到问题
2016/09/23 Javascript
javascript iframe跨域详解
2016/10/26 Javascript
Angular.JS通过指令操作DOM的方法
2017/05/10 Javascript
详解webpack 入门总结和实践(按需异步加载,css单独打包,生成多个入口文件)
2017/06/20 Javascript
Vue刷新修改页面中数据的方法
2018/09/16 Javascript
layui form.render('select', 'test2') 更新渲染的方法
2019/09/27 Javascript
[02:46]2014DOTA2国际邀请赛 选手为你解读比赛MVP充满梦想
2014/07/09 DOTA
[37:45]完美世界DOTA2联赛PWL S3 LBZS vs Phoenix 第二场 12.09
2020/12/11 DOTA
采用Psyco实现python执行速度提高到与编译语言一样的水平
2014/10/11 Python
Python中的变量和作用域详解
2016/07/13 Python
python调用摄像头显示图像的实例
2018/08/03 Python
分享Python切分字符串的一个不错方法
2018/12/14 Python
Python+PyQt5实现美剧爬虫可视工具的方法
2019/04/25 Python
django 微信网页授权登陆的实现
2019/07/30 Python
深入了解python中元类的相关知识
2019/08/29 Python
python3 dict ndarray 存成json,并保留原数据精度的实例
2019/12/06 Python
Pandas+Matplotlib 箱式图异常值分析示例
2019/12/09 Python
浅析Python requests 模块
2020/10/09 Python
校运会入场式解说词
2014/02/10 职场文书
大学生学习2014年全国两会心得体会
2014/03/12 职场文书
计算机专业应届生求职信
2014/04/06 职场文书
小学优秀班集体申报材料
2014/05/25 职场文书
咖啡店创业计划书范文
2014/09/15 职场文书
国际残疾人日广播稿范文
2014/10/09 职场文书
2014年财务工作总结与计划
2014/12/08 职场文书
2015年化工厂工作总结
2015/05/04 职场文书
2015学校年度工作总结
2015/05/11 职场文书
2019朋友新婚祝福语精选
2019/10/10 职场文书
python 下载文件的几种方式分享
2021/04/07 Python
深入理解margin塌陷和margin合并的解决方案
2021/06/26 HTML / CSS