日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

python大学生信息管理系统_python学生信息管理系统

發布時間:2025/4/5 40 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python大学生信息管理系统_python学生信息管理系统 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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大学生信息管理系统_python学生信息管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。