python学生信息管理系统实现代码
作者:飞上蓝天! 时间:2023-10-31 06:18:10
1.本人第一次学python做出来的,当时满满的成就感,当作纪念!!!!!
非常简单,复制即可使用
代码块
import json#把字符串类型的数据转换成Python基本数据类型或者将Python基本数据类型转换成字符串类型。
def login_user():
while True:
register=input('学生姓名:')
try:
with open(register+'.json')as file_object:
user_message=json.load(file_object)#json.load(obj) 读取文件中的字符串,序列化成Python的基本数据类型
except FileNotFoundError:
print('该用户不存在!')
break
else:
print('_'*20)
register_password = input('请输入学号:')
if user_message['id']==register and user_message['password']==register_password:
str_print = '姓名:{}\t数学成绩:{}\t语文成绩:{}\t英语成绩: {}'
grade_list = []
while 1:
print('''******************************
欢迎使用【学生信息管理系统】
请选择你想要进行的操作
1.新建学生信息
2.显示全部信息
3.查询学生信息
4.删除学生信息
5.修改学生信息
0.退出系统
******************************''')
action = input('请选择你想要的进行操作:\n')
if action == '1':
'''新建学生信息'''
name = input('请输入名字')
math = input('请输入数学成绩')
chinese = input('请输入语文成绩')
english = input('请输入英语成绩')
total = int(math) + int(chinese) + int(english)
grade_list.append([name,math,chinese,english,total])
print([name,math,chinese,english,total])
print('姓名:{}\t数学成绩:{}\t语文成绩:{}\t英语成绩: {}'.format(name,math,chinese,english,total))
pass
elif action == '2':
'''显示全部信息'''
for info in grade_list:
print(str_print.format(*info))
elif action == '3':
'''查询学生信息'''
name = input('请输入你需要查询学生的姓名:')
for info in grade_list:
if name in info:
print(str_print.format(*info))
break
else:
print('此学生不存在')
elif action == '4':
'''删除学生信息'''
name = input('请输入你需要查询学生的姓名:')
for info in grade_list:
if name in info:
info_=grade_list.pop(grade_list.index(info))
print('这个学员的信息已经被删除\n',info_)
break
else:
print('此学生不存在')
elif action == '5':
'''修改学生信息'''
name = input('请输入你需要查询学生的姓名:')
for info in grade_list:
if name in info:
index = grade_list.index(info)
break
else:
print('此学生不存在')
continue
math = input('请输入数学成绩:')
chinese = input('请输入语文成绩:')
english = input('请输入英语成绩:')
total = int(math) + int(chinese) + int(english)
grade_list[index][0:] = [name,math,chinese,english,total]
print('修改后的一个成绩',grade_list[index])
elif action == '0':
'''退出系统'''
break
else:
print('输入信息有误,请重新输入')
#print('登陆成功')
return register,user_message
else:
print('登陆失败!用户名或密码错误')
break
def register_user():
new_user=input('增加学生姓名:')
try:
with open(new_user+',.jion','r') as file_object:
pass
except FileNotFoundError:
new_password_one=input('请确认学号:')
new_password_two=input('请再次确认学号:')
if new_password_one==new_password_two:
user_message={'id':new_user,'password':new_password_one}
with open(new_user+'.json','w')as file_object:
json.dump(user_message,file_object)#json.dump(obj) 将Python的基本数据类型序列化成字符串并写入到文件中
print('新用户已经注册成功!可以登录了。')
else:
print('两次输入不一致')
else:
print('该用户已经存在')
while True:
print('*'*50)
print('* 1.登录用户 *')
print('* *')
print('* 2.注册用户 *')
print('* *')
print('* 3.退出 *')
print('*'*50)
test_content=input('请输入你的选项:')
if test_content=='1':
try:
user_id,user_system=login_user()
pass
except TypeError:
print('请重新输入')
# print('登录用户!')
elif test_content=='2':
register_user()
#print('注册用户')
elif test_content=='3':
print('退出系统')
break
else:
print('非法输入字符')
效果图(里面的全部功能都可以实现)
总结
以上所述是小编给大家介绍的python学生信息管理系统实现代码网站的支持!
如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!
来源:https://blog.csdn.net/weixin_43321726/article/details/103569640
标签:python,学生,信息,管理系统
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
js实现网页标题栏闪烁提示效果实例分析
2024-04-16 09:05:11
Python 中使用 PyMySQL模块操作数据库的方法
2024-01-26 04:23:11
ubuntu环境下python虚拟环境的安装过程
2022-07-25 06:09:07
js控制输入框获得和失去焦点时状态显示的方法
2024-04-17 10:24:04
详细分析Python垃圾回收机制
2021-04-18 02:43:43
![](https://img.aspxhome.com/file/2023/1/100821_0s.png)
pytorch中使用cuda扩展的实现示例
2021-02-17 23:46:55
python机器学习sklearn实现识别数字
2023-08-18 17:57:19
![](https://img.aspxhome.com/file/2023/8/83988_0s.png)
tensorflow模型转ncnn的操作方式
2022-10-29 15:55:19
python unicodedata模块用法
2021-04-05 20:53:55
python 中的int()函数怎么用
2021-05-21 17:52:41
MAC 中mysql密码忘记解决办法
2024-01-18 04:13:48
Python海龟绘图详解
2022-07-26 02:02:02
![](https://img.aspxhome.com/file/2023/7/133427_0s.png)
解决pytorch中的kl divergence计算问题
2023-11-12 11:02:00
![](https://img.aspxhome.com/file/2023/9/69459_0s.jpg)
python 从远程服务器下载东西的代码
2023-01-23 11:00:55
python 如何求N的阶乘
2023-11-01 15:24:46
Python3 修改默认环境的方法
2023-04-01 16:23:36
asp实现树型结构
2008-04-13 06:06:00
Python爬虫爬取杭州24时温度并展示操作示例
2022-01-04 14:43:33
![](https://img.aspxhome.com/file/2023/1/81741_0s.png)
python实现将一个数组逆序输出的方法
2022-07-16 11:07:51
python 使用pygame工具包实现贪吃蛇游戏(多彩版)
2021-05-10 17:29:19
![](https://img.aspxhome.com/file/2023/3/105383_0s.jpg)