python实现学生管理系统开发

时间:2021-11-05 07:33:29

使用python完成超级基础的学生管理系统,供大家参考,具体内容如下

说明:

1、本学生管理系统非常非常简易,只有增,显,查,删,改功能,对于Python新手容易看懂上手。
2、信息的存储只使用了字典和列表。
3、不喜勿喷。

代码:

1、主循环框架

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
while True:
 
 print(info_str)
 action = input("请输入想要进行的操作:")
 
 if action == '0':
 
  print("再见。")
  break
 elif action == '1':
  print("新建学生信息")
 
 elif action == '2':
  print("显示全部学生")
 
 elif action == '3':
  print("查询学生信息")
 
 elif action == '4':
  print("删除学生信息")
 
 elif action == '5':
  print("修改学生信息")
 
 else:
  print("你的输入有错误,请重新输入。")

2、源代码

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
info_str = """
*************************
1.新建学生信息
2.显示全部学生
3.查询学生信息
4.删除学生信息
5.修改学生信息
0.退出系统
*************************
"""
 
"""姓名、语文成绩、数学成绩、英语成绩、总分"""
students = [
 {'Name':'张大炮','Chinese':'95','Math':'65','English':'65','Score':'215'},
 {'Name':'张益达','Chinese':'65','Math':'95','English':'65','Score':'215'},
 {'Name':'Snack','Chinese':'65','Math':'65','English':'95','Score':'215'},
]
 
 
while True:
 """"程序主循环"""
 print(info_str)
 action = input("请输入想要进行的操作:")
 
 if action == '0':
  """结束条件"""
  print("撒由那拉。")
  break
 elif action == '1':
  print("新建学生信息")
  Name = input("请输入名字:")
  Chinese = input("请输入语文成绩:")
  Math = input("请输入数学成绩:")
  English = input("请输入英语成绩:")
  Score = int(Chinese) + int(Math) + int(English)
  student={
   'Name':Name,
   'Chinese':Chinese,
   'Math':Math,
   'English':English,
   'Score':Score
   }
  students.append(student)
 elif action == '2':
  print("显示全部学生")
  for student in students:
   print(student)
 elif action == '3':
  print("查询学生信息")
  Name = input('请输入需要查询的名字:')
  for student in students:
   if student['Name'] == Name:
    print(student)
  else:
    print("{}信息不存在".format(Name))
 elif action == '4':
  print("删除学生信息")
  Name = input("请输入需要删除的名字:")
  for student in students:
   if student['Name'] == Name:
    students.remove(student)
    break
  else:
   print("{}信息不存在".format(Name))
 elif action == '5':
  print("修改学生信息")
  Name = input("请输入需要修改的名字:")
  for student in students:
   if student['Name'] == Name:
    student['Name'] = input("请输入名字:")
    student['Chinese'] = input("请输入语文成绩:")
    student['Math'] = input("请输入数学成绩:")
    student['English'] = input("请输入英语成绩:")
    student['Score'] = int(student['Chinese']) + int(student['Math']) + int(student['English'])
  else:
   print("{}信息不存在".format(Name))
 else:
  print("你的输入有错误,请重新输入。")

总结

1、代码框架简洁明了,添加功能只需要在主循环中增加即可。
2、超级基础,不喜勿喷。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:https://blog.csdn.net/flower10_/article/details/106954056