網(wǎng)站首頁 編程語言 正文
本文實例為大家分享了Python實現(xiàn)學(xué)生管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
功能描述
1.分為兩個界面:(1)登錄和注冊界面 (2)學(xué)生管理系統(tǒng)界面
2.登錄功能和之前發(fā)布的圖書管理系統(tǒng)相同,登錄成功后可進入學(xué)生管理系統(tǒng)界面,這里不再敘述
3.系統(tǒng)功能(1)添加學(xué)生信息(2)刪除學(xué)生信息(3)修改學(xué)生信息(4)查詢學(xué)生信息(5)顯示所有學(xué)生信息(6)退出
4.有很多地方增加了優(yōu)化,也進行了完善,如模塊導(dǎo)入、登錄注冊以及回車不修改等功能。整個程序代碼大概200行。
注意:代碼分為兩個模塊,需要在student_main模塊中啟動。student_main模塊中只負責輸入操作,而student_tools模塊中負責具體的學(xué)生信息系統(tǒng)操作實現(xiàn)功能。所以大家在拷貝代碼的時候記得創(chuàng)建兩個.py文件。
完整代碼如下
student_main模塊內(nèi)容代碼:
import student_tools
user=['wangtaotao']
pwd=['123456']
#登錄
def denglu():
? ? users = input("請輸入您的用戶名:")
? ? pwds = input("請輸入您的密碼:")
? ? if users in user and pwds in pwd:
? ? ? ? student()
? ? else:
? ? ? ? print("賬號或密碼不正確,請重新輸入")
#注冊
def zhuce():
? ? users=input("請輸入您要注冊的用戶名:")
? ? pwds=input("請輸入您要注冊的密碼:")
? ? user.append(users)
? ? pwd.append(pwds)
? ? print()
? ? print("注冊成功!")
? ? print()
#登錄界面
def dljiemian():
? ? while True:
? ? ? ? print("---------------------------")
? ? ? ? print(" ? ?學(xué)生管理系統(tǒng)登陸界面 V1.0 ?")
? ? ? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ? ")
? ? ? ? print(" ? ? ? ?1:登 ? 錄 ? ? ? ? ? ")
? ? ? ? print(" ? ? ? ?2:注 ? 冊 ? ? ? ? ? ")
? ? ? ? print(" ? ? ? ?3:退 ? 出 ? ? ? ? ? ")
? ? ? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ? ")
? ? ? ? print("---------------------------")
? ? ? ? xx=input("請輸入您的選擇:")
? ? ? ? #1.登錄
? ? ? ? if xx=='1':
? ? ? ? ? ? denglu()
? ? ? ? elif xx=='2':
? ? ? ? #2.注冊
? ? ? ? ? ? zhuce()
? ? ? ? elif xx=='3':
? ? ? ? #3.退出
? ? ? ? ? ? print()
? ? ? ? ? ? print("成功退出!")
? ? ? ? ? ? print()
? ? ? ? ? ? break
? ? ? ? else:
? ? ? ? ? ? print("輸入錯誤,請重新輸入")
#學(xué)生管理系統(tǒng)
def student():
? ? while True:
? ? ? ? #調(diào)用student_tools模塊中的界面函數(shù)
? ? ? ? student_tools.jiemian()
? ? ? ? x=input("請輸入您的選擇:")
? ? ? ? #添加學(xué)生
? ? ? ? if x=='1':
? ? ? ? ? ? student_tools.add()
? ? ? ? #刪除學(xué)生
? ? ? ? elif x=='2':
? ? ? ? ? ? student_tools.dele()
? ? ? ? #修改學(xué)生
? ? ? ? elif x=='3':
? ? ? ? ? ? student_tools.xiugai()
? ? ? ? #查詢學(xué)生
? ? ? ? elif x=='4':
? ? ? ? ? ? student_tools.find()
? ? ? ? #顯示所有學(xué)生
? ? ? ? elif x=='5':
? ? ? ? ? ? student_tools.showall()
? ? ? ? #退出學(xué)生管理系統(tǒng),返回上一層登錄界面系統(tǒng)
? ? ? ? elif x=='6':
? ? ? ? ? ? print()
? ? ? ? ? ? print("成功退出學(xué)生管理系統(tǒng)!")
? ? ? ? ? ? break
? ? ? ? else:
? ? ? ? ? ? print()
? ? ? ? ? ? print("輸入錯誤,請重新輸入")
? ? ? ? ? ? print()
#調(diào)用最先執(zhí)行的登錄界面函數(shù)
dljiemian()
student_tools模塊內(nèi)容代碼:
student_list=[]
student_dict={}
#學(xué)生管理系統(tǒng)界面
def jiemian():
? ? print("---------------------------")
? ? print(" ? ? ?學(xué)生管理系統(tǒng) V1.0")
? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ? ")
? ? print(" ? ? ?1:添加學(xué)生" ? ? ? ? ? ?)
? ? print(" ? ? ?2:刪除學(xué)生" ? ? ? ? ? ?)
? ? print(" ? ? ?3:修改學(xué)生" ? ? ? ? ? ?)
? ? print(" ? ? ?4:查詢學(xué)生" ? ? ? ? ? ?)
? ? print(" ? ? ?5:顯示所有學(xué)生" ? ? ? ? )
? ? print(" ? ? ?6:退出系統(tǒng)" ? ? ? ? ? ?)
? ? print(" ? ? ? ? ? ? ? ? ? ? ? ? ? ")
? ? print("---------------------------")
#添加學(xué)生
def add():
? ? name=input("請輸入錄入學(xué)生姓名:")
? ? cls=input("請輸入學(xué)生班級:")
? ? age=input("請輸入錄入學(xué)生年齡:")
? ? phone=input("請輸入錄入學(xué)生手機號:")
? ? addr=input("請輸入錄入學(xué)生家庭住址:")
? ? student_dict={"name":name,"class":cls,"age":age,"phone":phone,"address":addr}
? ? student_list.append(student_dict)
? ? print()
? ? print("-----添加學(xué)生信息界面-----")
? ? print()
? ? print("姓名\t\t","班級\t\t","年齡\t\t","電話號\t\t","家庭住址\t\t")
? ? for student_dict_1 in student_list:
? ? ? ? print("%s\t\t%s\t\t%s\t\t%s\t\t%s" %(student_dict_1["name"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["class"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["age"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["phone"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["address"]))
? ? print()
? ? print("錄入成功!")
? ? print()
#刪除學(xué)生
def dele():
? ? name_del=input("請輸入想要刪除的學(xué)生姓名:")
? ? for student_dict_1 in student_list:
? ? ? ? if name_del in student_dict_1["name"]:
? ? ? ? ? ? student_list.remove(student_dict_1)
? ? ? ? ? ? print()
? ? ? ? ? ? print("刪除%s信息成功!" % name_del)
? ? ? ? ? ? print()
? ? ? ? ? ? break
? ? else:
? ? ? ? print()
? ? ? ? print("您輸入的學(xué)生姓名錯誤,請重新輸入")
? ? ? ? print()
#修改學(xué)生
def xiugai():
? ? name_xiugai=input("請輸入想要修改的學(xué)生姓名:")
? ? for student_dict_1 in student_list:
? ? ? ? if name_xiugai == student_dict_1["name"]:
? ? ? ? ? ? print()
? ? ? ? ? ? print("-----修改界面-----")
? ? ? ? ? ? print()
? ? ? ? ? ? print("姓名\t\t", "班級\t\t", "年齡\t\t", "電話號\t\t", "家庭住址\t\t")
? ? ? ? ? ? print("%s\t\t%s\t\t%s\t\t%s\t\t%s" %(student_dict_1["name"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["class"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["age"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["phone"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?student_dict_1["address"]))
? ? ? ? ? ? #回車不修改
? ? ? ? ? ? student_dict_1["name"]=new_input(student_dict_1["name"],"請輸入修改后的學(xué)生姓名[回車不修改]:")
? ? ? ? ? ? student_dict_1["class"]=new_input(student_dict_1["class"],"請輸入修改后的學(xué)生班級[回車不修改]:")
? ? ? ? ? ? student_dict_1["age"]=new_input(student_dict_1["age"],"請輸入修改后的學(xué)生年齡[回車不修改]:")
? ? ? ? ? ? student_dict_1["phone"]=new_input(student_dict_1["phone"],"請輸入修改后的學(xué)生手機號[回車不修改]:")
? ? ? ? ? ? student_dict_1["address"]=new_input(student_dict_1["address"],"請輸入修改后的學(xué)生家庭地址[回車不修改]:")
? ? ? ? ? ? print()
? ? ? ? ? ? print("修改成功!")
? ? ? ? ? ? print()
? ? ? ? ? ? break
? ? else:
? ? ? ? print()
? ? ? ? print("您輸入的學(xué)生姓名錯誤,請重新輸入")
? ? ? ? print()
#查找學(xué)生
def find():
? ? find_name=input("請輸入需要查找的學(xué)生姓名:")
? ? for student_dict_1 in student_list:
? ? ? ? if find_name == student_dict_1["name"]:
? ? ? ? ? ? print()
? ? ? ? ? ? print("-----查詢結(jié)果界面-----")
? ? ? ? ? ? print()
? ? ? ? ? ? print("姓名\t\t", "班級\t\t", "年齡\t\t", "電話號\t\t", "家庭住址\t\t")
? ? ? ? ? ? print("%s\t\t%s\t\t%s\t\t%s\t\t%s" % (student_dict_1["name"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["class"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["age"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["phone"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["address"]))
? ? ? ? else:
? ? ? ? ? ? print()
? ? ? ? ? ? print("-----查詢結(jié)果界面-----")
? ? ? ? ? ? print()
? ? ? ? ? ? print("無此學(xué)生信息")
#顯示所有學(xué)生信息
def showall():
? ? print()
? ? print("-----顯示所有學(xué)生信息-----")
? ? print()
? ? print("姓名\t\t", "班級\t\t", "年齡\t\t", "電話號\t\t", "家庭住址\t\t")
? ? for student_dict_1 in student_list:
? ? ? ? print(student_dict_1)
? ? ? ? print("%s\t\t%s\t\t%s\t\t%s\t\t%s" % (student_dict_1["name"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["class"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["age"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["phone"],
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? student_dict_1["address"]))
#設(shè)置用戶不輸入內(nèi)容返回原值,輸入內(nèi)容返回新內(nèi)容
def new_input(yuanzhi,message):
? ? input_str=input(message)
? ? if len(input_str)>0:
? ? ? ? return input_str
? ? else:
? ? ? ? return yuanzhi
原文鏈接:https://blog.csdn.net/WangTaoTao_/article/details/95054880
相關(guān)推薦
- 2022-04-03 Python中的tkinter庫簡單案例詳解_python
- 2022-12-26 C++?Boost?log日志庫超詳細講解_C 語言
- 2021-12-20 使用Docker構(gòu)建開發(fā)環(huán)境的方法步驟(?Windows和mac)_docker
- 2022-03-28 用python實現(xiàn)一個文件搜索工具_python
- 2022-07-01 python神經(jīng)網(wǎng)絡(luò)Pytorch中Tensorboard函數(shù)使用_python
- 2023-02-01 python?multiply()與dot使用示例講解_python
- 2023-06-02 關(guān)于pip安裝opencv-python遇到的問題_python
- 2022-03-03 GitHub 私人private倉庫添加成員(協(xié)作者Collaborators)
- 最近更新
-
- window11 系統(tǒng)安裝 yarn
- 超詳細win安裝深度學(xué)習(xí)環(huán)境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎(chǔ)操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區(qū)別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權(quán)
- redisson分布式鎖中waittime的設(shè)
- maven:解決release錯誤:Artif
- restTemplate使用總結(jié)
- Spring Security之安全異常處理
- MybatisPlus優(yōu)雅實現(xiàn)加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務(wù)發(fā)現(xiàn)-Nac
- Spring Security之基于HttpR
- Redis 底層數(shù)據(jù)結(jié)構(gòu)-簡單動態(tài)字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應(yīng)用詳解
- 聊聊消息隊列,發(fā)送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支