python大学生信息管理系统_python学生信息管理系统
1.本人第一次學(xué)python做出來的,當(dāng)時滿滿的成就感,當(dāng)作紀(jì)念!!!!!
非常簡單,復(fù)制即可使用
代碼塊
import json#把字符串類型的數(shù)據(jù)轉(zhuǎn)換成Python基本數(shù)據(jù)類型或者將Python基本數(shù)據(jù)類型轉(zhuǎn)換成字符串類型。
def login_user():
while True:
register=input('學(xué)生姓名:')
try:
with open(register+'.json')as file_object:
user_message=json.load(file_object)#json.load(obj) 讀取文件中的字符串,序列化成Python的基本數(shù)據(jù)類型
except FileNotFoundError:
print('該用戶不存在!')
break
else:
print('_'*20)
register_password = input('請輸入學(xué)號:')
if user_message['id']==register and user_message['password']==register_password:
str_print = '姓名:{}\t數(shù)學(xué)成績:{}\t語文成績:{}\t英語成績: {}'
grade_list = []
while 1:
print('''******************************
歡迎使用【學(xué)生信息管理系統(tǒng)】
請選擇你想要進(jìn)行的操作
1.新建學(xué)生信息
2.顯示全部信息
3.查詢學(xué)生信息
4.刪除學(xué)生信息
5.修改學(xué)生信息
0.退出系統(tǒng)
******************************''')
action = input('請選擇你想要的進(jìn)行操作:\n')
if action == '1':
'''新建學(xué)生信息'''
name = input('請輸入名字')
math = input('請輸入數(shù)學(xué)成績')
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數(shù)學(xué)成績:{}\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':
'''查詢學(xué)生信息'''
name = input('請輸入你需要查詢學(xué)生的姓名:')
for info in grade_list:
if name in info:
print(str_print.format(*info))
break
else:
print('此學(xué)生不存在')
elif action == '4':
'''刪除學(xué)生信息'''
name = input('請輸入你需要查詢學(xué)生的姓名:')
for info in grade_list:
if name in info:
info_=grade_list.pop(grade_list.index(info))
print('這個學(xué)員的信息已經(jīng)被刪除\n',info_)
break
else:
print('此學(xué)生不存在')
elif action == '5':
'''修改學(xué)生信息'''
name = input('請輸入你需要查詢學(xué)生的姓名:')
for info in grade_list:
if name in info:
index = grade_list.index(info)
break
else:
print('此學(xué)生不存在')
continue
math = input('請輸入數(shù)學(xué)成績:')
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':
'''退出系統(tǒng)'''
break
else:
print('輸入信息有誤,請重新輸入')
#print('登陸成功')
return register,user_message
else:
print('登陸失敗!用戶名或密碼錯誤')
break
def register_user():
new_user=input('增加學(xué)生姓名:')
try:
with open(new_user+',.jion','r') as file_object:
pass
except FileNotFoundError:
new_password_one=input('請確認(rèn)學(xué)號:')
new_password_two=input('請再次確認(rèn)學(xué)號:')
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的基本數(shù)據(jù)類型序列化成字符串并寫入到文件中
print('新用戶已經(jīng)注冊成功!可以登錄了。')
else:
print('兩次輸入不一致')
else:
print('該用戶已經(jīng)存在')
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('退出系統(tǒng)')
break
else:
print('非法輸入字符')
總結(jié)
以上是生活随笔為你收集整理的python大学生信息管理系统_python学生信息管理系统的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基金是股票的意思吗
- 下一篇: java 查找 替换_java 查找、替