Python實現一個簡單的畢業生信息管理系統的示例代碼
寫在前面:
從昨晚的夢里回憶起數據管理的作業:實現一個自己的選題----畢業生信息管理系統,實現學生個人信息基本的增刪改查,我想了想前段時間剛學習的列表,這個簡單啊 ,設計一個學生信息列表,然后列表里面再存每個學生詳細信息的列表,然后來實現一個基本的增刪查改,這個不難啊!直接開始擼代碼!
上代碼!
def Menu():##菜單主界面 print(’*’*22) print('* 查看畢業生列表輸入: 1 *') print('* 添加畢業生信息輸入: 2 *') print('* 修改畢業生信息輸入: 3 *') print('* 刪除畢業生信息輸入: 4 *') print('* 退出系統請輸入 0 *') print(’*’*22)def CheckIdisRight(StudentList,id):##檢查學號是否在列表中 for i in range(0, len(StudentList)): if((id in StudentList[i])==True): return True return Falsedef PrintStudentList(StudentList):#打印學生信息列表 for i in range(0, len(StudentList)): print(StudentList[i])def AddStudent(StudentList):##添加學生信息 number = int((input('請輸入學號: '))) if(number<1000000000 and CheckIdisRight(StudentList,number)==False):##學號判斷 print('學號輸入錯誤&學號已存在!請重新輸入:') number = (input('請輸入學號: ')) name = input('請輸入你的名字:') tell = input('請輸入你的電話:') if(len(tell)!=11): print('請輸入正確的電話號碼(11)位: ') tell = input() college = input('請輸入你的學院名稱:') grade = input('請輸入你的年級:') isjob = int(input('是否就業?:是填 1 否則填0: ')) if(isjob == 1): company = input('請輸入你公司的名稱:') else: company = 0 arry = [number, name, tell, college, grade, isjob, company] StudentList.append(arry)##將新建的學生信息進行插入 PrintStudentList(StudentList)##打印學生信息列表def StudentPersonalMsg():##修改信息界面選擇 print(’*’ * 22) print('* 修改姓名請輸入: 1 *') print('* 修改電話號碼請輸入: 2 *') print('* 修改是否就業請輸入: 3 *') print('* 修改就業公司請輸入: 4 *') print('* 退出修改請輸入: 0 *') print(’*’ * 22)def ChangeStudent(StudentList):##修改學生信息模塊 ##默認學號 年級 等信息不可修改 def changename(StudentList, arry, i):#修改姓名 print(arry) name = input('請輸入修改后的名字:') StudentList[i][1] = name print('修改后為:') PrintStudentList(StudentList) def changetell(StudentList, arry, i):#修改電話號碼 print(arry) tell = input('請輸入修改后的電話號碼:') StudentList[i][2] = tell print('修改后為:') PrintStudentList(StudentList) def changeisgob(StudentList, arry, i):#修改是否就業情況 print(arry) isgob = int(input('請輸入修改后的 是否工作:')) StudentList[i][5] = isgob print('修改后為:') PrintStudentList(StudentList) def changcompany(StudentList, arry, i):#修改就業公司信息 print(arry) company = input('請輸入修改后的公司為:') StudentList[i][6] = company print('修改后為:') PrintStudentList(StudentList) print('請輸入要修改的學生的學號:') id = int(input()) i=1 if((CheckIdisRight(StudentList,id))==False):##判斷學號是否存在 print('學號不存在!') if(CheckIdisRight(StudentList,id)==True): while (i < len(StudentList)):#通過循環找到該學生的信息列表 if (StudentList[i][0] == id):StudentPersonalMsg()##顯示出修改的菜單選項while (1): a = int(input('請輸入: ')) while (a): if (a == 1): ##姓名修改 changename(StudentList, StudentList[i], i) break if (a == 2): ##電話號碼修改 changetell(StudentList, StudentList[i], i) break if (a == 3): ##是否就業狀態修改 changeisgob(StudentList, StudentList[i], i) break if (a == 4 and StudentList[i][5] == 1): ##就業公司修改 changcompany(StudentList, StudentList[i], i) break if (a == 4 and StudentList[i][5] == 0): print('學生尚未就業,請先修改是否就業信息!') break if (a == 0): ##按0 退出修改信息功能 break##返回到主界面的菜單選項break i = i + 1def DeleteStudent(StudentList):##刪除學生信息 print('請輸入要刪除的學生的學號:輸入0退出!') id = int(input()) i = 1 if((CheckIdisRight(StudentList,id))==False): print('學號不存在!') if(CheckIdisRight(StudentList,id)==True): ##同樣先判斷學號學號是否存在 while (i < len(StudentList)): if (StudentList[i][0] == id): del StudentList[i] print('刪除成功!') break if (id == 0): break i = i + 1 PrintStudentList(StudentList)#打印學生信息列表def main(): Menu() StudentInfo = [’學號’, ’姓名’, ’電話’, ’學院’, ’年級’, ’是否就業’, '就業公司'] ##先默認插入一個用于顯示的列表的列表 StudentList = [StudentInfo] while(1): a = int(input('請輸入: ')) while(a): if(a==1):PrintStudentList(StudentList)Menu()break if(a==2):AddStudent(StudentList)Menu()break if(a==3):ChangeStudent(StudentList)Menu()break if(a==4):DeleteStudent(StudentList)Menu()break if (a == 0):##按0退出進程 exit()main()
再看測試效果圖:
主界面
1.查看畢業學生信息列表
2.增加畢業學生信息
3.修改畢業學生信息
4.刪除畢業生信息
大致實現了一下功能,但是萬萬沒想到!!!
一時語塞的我 :我 *******(這就是不看文檔的后果吧!)
算了算了,再重寫一個!
到此這篇關于Python實現一個簡單的畢業生信息管理系統的示例代碼的文章就介紹到這了,更多相關Python 畢業生信息管理系統內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!
相關文章: