python學(xué)生信息管理系統(tǒng)實現(xiàn)代碼
1.本人第一次學(xué)python做出來的,當時滿滿的成就感,當作紀念?。。。?!
非常簡單,復(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)】
請選擇你想要進行的操作
1.新建學(xué)生信息
2.顯示全部信息
3.查詢學(xué)生信息
4.刪除學(xué)生信息
5.修改學(xué)生信息
0.退出系統(tǒng)
******************************''')
action = input('請選擇你想要的進行操作:\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('請確認學(xué)號:')
new_password_two=input('請再次確認學(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('非法輸入字符')
效果圖(里面的全部功能都可以實現(xiàn))

總結(jié)
以上所述是小編給大家介紹的python學(xué)生信息管理系統(tǒng)實現(xiàn)代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!
如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!
- python學(xué)生信息管理系統(tǒng)(完整版)
- Python實現(xiàn)GUI學(xué)生信息管理系統(tǒng)
- python實現(xiàn)學(xué)生信息管理系統(tǒng)
- python實現(xiàn)簡易學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)
- python實現(xiàn)簡單學(xué)生信息管理系統(tǒng)
- python學(xué)生信息管理系統(tǒng)(初級版)
- python學(xué)生信息管理系統(tǒng)實現(xiàn)代碼
- python代碼實現(xiàn)學(xué)生信息管理系統(tǒng)
- Python結(jié)合MySQL數(shù)據(jù)庫編寫簡單信息管理系統(tǒng)完整實例
相關(guān)文章
Python數(shù)據(jù)分析matplotlib折線圖案例處理
這篇文章主要介紹了Python數(shù)據(jù)分析matplotlib折線圖案例處理,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下2022-08-08
python自動化腳本安裝指定版本python環(huán)境詳解
這篇文章主要為大家詳細介紹了python自動化腳本安裝指定版本python環(huán)境的相關(guān)方法,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09
Python實現(xiàn)將內(nèi)容寫入文件的五種方法總結(jié)
本篇帶你詳細看一下python將內(nèi)容寫入文件的方法以及細節(jié),主要包括write()方法、writelines()?方法、print()?函數(shù)、使用?csv?模塊、使用?json?模塊,需要的可以參考一下2023-04-04
django框架實現(xiàn)模板中獲取request 的各種信息示例
這篇文章主要介紹了django框架實現(xiàn)模板中獲取request 的各種信息,結(jié)合實例形式分析了Django框架模板直接獲取request信息的相關(guān)配置與操作技巧,需要的朋友可以參考下2019-07-07

