本文实例为大家分享了python学生信息管理系统的具体代码,供大家参考,具体内容如下
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#编译环境为python3 #学生信息管理系统包括基本的信息功能,能够实现学生信息的输入,查询,增添和删除 #基本框架:开始操作菜单,接收输入选项,调用相应的函数实现对应的功能,循环回到开始菜单, #操作菜单: student = [] def studentMeau(): print ( '-' * 30 ) print ( '-------学生信息管理系统-------' ) print ( ' 1、添加学生信息' ) print ( ' 2、删除学生信息' ) print ( ' 3、查询学生信息' ) print ( ' 4、修改学生信息' ) print ( ' 5、退出' ) print ( '-' * 30 ) def appendStuInf(): studentInf = { 'Name' :' ',' Id ':' ',' Sex ':' ',' Age ':' ',' Project ':' '} studentInf[ 'Name' ] = input ( '请输入学生姓名:' ) studentInf[ 'Id' ] = input ( '请输入学生学号:' ) studentInf[ 'Sex' ] = input ( '请输入学生性别:' ) studentInf[ 'Age' ] = input ( '请输入学生年龄:' ) studentInf[ 'Project' ] = input ( '请输入学生专业:' ) student.append(studentInf) #print(student) def deleteStuInf(): num = input ( '请输入要删除学生的学号:' ) # for i in range(len(student)): # if student[i]['Id'] == num: # student.remove(student[i]) # break for stu_inf in student: if stu_inf[ 'Id' ] = = num: student.remove(stu_inf) break # print(student) def inquireStuInf(): flag = False num = input ( '请输入要查询学生的学号:' ) for stu_inf in student: if stu_inf[ 'Id' ] = = num: print ( 'name: ' + stu_inf[ 'Name' ] + '\n' ) print ( 'Id: ' + stu_inf[ 'Id' ] + '\n' ) print ( 'Sex: ' + stu_inf[ 'Sex' ] + '\n' ) print ( 'Age: ' + stu_inf[ 'Age' ] + '\n' ) print ( 'Project: ' + stu_inf[ 'Project' ] + '\n' ) flag = True break if flag = = False : print ( '没有查询到该生的信息!' ) def modifyStuInf(): num = input ( '请输入要修改学生的学号:' ) flag = False for stu_inf in student: if stu_inf[ 'Id' ] = = num: print ( 'name: ' + stu_inf[ 'Name' ] + '\n' ) print ( 'Id: ' + stu_inf[ 'Id' ] + '\n' ) print ( 'Sex: ' + stu_inf[ 'Sex' ] + '\n' ) print ( 'Age: ' + stu_inf[ 'Age' ] + '\n' ) print ( 'Project: ' + stu_inf[ 'Project' ] + '\n' ) flag = True break if flag = = False : print ( '没有该生的信息!' ) return print ( '1:姓名 ---- 2:学号 ---- 3:性别 ---- 4:年龄 ---- 5:专业 ---- 6:退出' + '\n' ) while True : choice = int ( input ( "请输入选项序号:" )) if choice = = 1 : stu_inf[ 'Name' ] = input ( '请重新输入姓名:' ) print ( '姓名已更正为:' + stu_inf[ 'Name' ] + '\n' ) elif choice = = 2 : stu_inf[ 'Id' ] = input ( '请重新输入学号:' ) print ( '学号已更正为:' + stu_inf[ 'Id' ] + '\n' ) elif choice = = 3 : stu_inf[ 'Sex' ] = input ( '请重新输入性别:' ) print ( '性别已更正为:' + stu_inf[ 'Sex' ] + '\n' ) elif choice = = 4 : stu_inf[ 'Age' ] = input ( '请重新输入年龄:' ) print ( '年龄已更正为:' + stu_inf[ 'Age' ] + '\n' ) elif choice = = 5 : stu_inf[ 'Project' ] = input ( '请重新输入专业:' ) print ( '专业已更正为:' + stu_inf[ 'Project' ] + '\n' ) elif choice = = 6 : print ( '修改完毕!' ) break else : print ( '输入有误,不予执行!' ) while True : studentMeau() choice = int ( input ( "请输入选项序号:" )) if choice = = 1 : #添加学生信息 appendStuInf() elif choice = = 2 : #删除学生信息 deleteStuInf() elif choice = = 3 : #查询学生信息 inquireStuInf() elif choice = = 4 : #修改学生信息 modifyStuInf() elif choice = = 5 : print ( '谢谢使用!' ) break else : print ( '输入有误,检查后重新输入!' ) |
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:http://blog.csdn.net/m0_37338590/article/details/78010630