python實現(xiàn)學生信息管理系統(tǒng)源碼
更新時間:2021年02月22日 15:38:49 作者:~浮生~
這篇文章主要為大家詳細介紹了python實現(xiàn)學生信息管理系統(tǒng)源碼,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
本文實例為大家分享了python實現(xiàn)學生信息管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下
代碼如下:
Project.py文件內(nèi)容:
class Student(object):
# 建立學生信息儲存的列表(嵌套的方式)
studentInformation = []
# 對學生對象的數(shù)據(jù)進行說明
studentShow = ["學號:", "姓名:", "年齡:"]
# 錄入學生
def addstudent(self):
sno = input("請輸入學號:")
name = input("請輸入姓名:")
sage = input("請輸入年齡:")
# 建立一個列表,用于暫時存儲
student = [sno, name, sage]
# 加入學生(判斷學號是否重復)
x = 0
# 剛開始錄入學生時,學號不可能重復
if len(self.studentInformation) == 0:
self.studentInformation.append(student)
# 判斷重復
else:
while x < len(self.studentInformation):
if self.studentInformation[x][0] != sno:
x += 1
else:
print("學號重復?。?!\n請重新輸入序號?。。?)
break
else:
self.studentInformation.append(student)
print("加入成功?。?!")
# 輸出學生
def showstudent(self):
print("學生信息輸出如下:")
for i in range(len(self.studentInformation)):
print(self.studentShow[0]+self.studentInformation[i][0], end=" ")
print(self.studentShow[1] + self.studentInformation[i][1], end=" ")
print(self.studentShow[2] + self.studentInformation[i][2])
# 刪除學生
def deletestudent(self):
x = 0
sno = input("請輸入學生學號:")
while x < len(self.studentInformation):
if self.studentInformation[x][0] == sno:
del self.studentInformation[x]
print("刪除學生成功!!!")
break
else:
x += 1
else:
print("不存在當前學生?。?!")
# 查詢學生
def selectstudent(self):
x = 0
sno = input("請輸入查詢學生的學號")
while x < len(self.studentInformation):
if self.studentInformation[x][0] == sno:
print(self.studentShow[0] + self.studentInformation[x][0], end=" ")
print(self.studentShow[1] + self.studentInformation[x][1], end=" ")
print(self.studentShow[2] + self.studentInformation[x][2])
break
else:
x += 1
else:
print("未查詢到當前學生?。?!")
# 修改學生
def changestudent(self):
x = 0
sno = input("請輸入修改學生的學號:")
while x < len(self.studentInformation):
if self.studentInformation[x][0] == sno:
name = input("請輸入修改后的姓名:")
sage = input("請輸入修改后的年齡:")
self.studentInformation[x][1] = name
self.studentInformation[x][2] = sage
print("修改成功!!!")
break
else:
x += 1
# 界面打印
@staticmethod
def printui():
print("輸入:0 --退出程序--")
print("輸入:1 --錄入學生--")
print("輸入:2 --輸出學生--")
print("輸入:3 --刪除學生--")
print("輸入:4 --查詢學生--")
print("輸入:5 --修改學生--")
# 程序調(diào)用
def run(self):
self.printui()
number = input("請輸入功能前面的代碼:")
# 無限循環(huán)
var = 1
while var == 1:
if int(number) == 1:
self.addstudent()
self.printui()
number = input("請輸入功能前面的代碼:")
elif int(number) == 2:
self.showstudent()
self.printui()
number = input("請輸入功能前面的代碼:")
elif int(number) == 3:
self.deletestudent()
self.printui()
number = input("請輸入功能前面的代碼:")
elif int(number) == 4:
self.selectstudent()
self.printui()
number = input("請輸入功能前面的代碼:")
elif int(number) == 5:
self.changestudent()
self.printui()
number = input("請輸入功能前面的代碼:")
elif int(number) == 0:
break
else:
print("您輸入的序號不對!\n請重新輸入!")
self.printui()
number = input("請輸入功能前面的代碼:")
else:
print("再見!")
exit()
text.py文件:
from Project import Student # 實例化對象 stu = Student() stu.run()
運行結(jié)果:





以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
pyqt5中QThread在使用時出現(xiàn)重復emit的實例
今天小編就為大家分享一篇pyqt5中QThread在使用時出現(xiàn)重復emit的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-06-06
在python中使用requests 模擬瀏覽器發(fā)送請求數(shù)據(jù)的方法
今天小編就為大家分享一篇在python中使用requests 模擬瀏覽器發(fā)送請求數(shù)據(jù)的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-12-12
Django與數(shù)據(jù)庫交互的實現(xiàn)
最近在學習Django,本文主要介紹了Django與數(shù)據(jù)庫交互的實現(xiàn),具有一定的參考價值,感興趣的小伙伴們可以參考一下2021-06-06
Django動態(tài)展示Pyecharts圖表數(shù)據(jù)的幾種方法
本文主要介紹了Django動態(tài)展示Pyecharts圖表數(shù)據(jù)的幾種方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2021-08-08

