這篇文章主要介紹了Python如何實現(xiàn)學校管理系統(tǒng),具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
成都創(chuàng)新互聯(lián)-專業(yè)網(wǎng)站定制、快速模板網(wǎng)站建設(shè)、高性價比鏡湖網(wǎng)站開發(fā)、企業(yè)建站全套包干低至880元,成熟完善的模板庫,直接使用。一站式鏡湖網(wǎng)站制作公司更省心,省錢,快速模板網(wǎng)站建設(shè)找我們,業(yè)務覆蓋鏡湖地區(qū)。費用合理售后完善,10余年實體公司更值得信賴。一、功能分析
此學校管理系統(tǒng)應該可以實現(xiàn)學校的師資力量的調(diào)配,學生的入學、學習以及修學或者退學的情況
二、程序解讀
1.下面的程序?qū)崿F(xiàn)了學校管理系統(tǒng)的基本功能,包括:
1)學校的招生
2)講師的招聘
3)課程的增加
4)等等
2.未實現(xiàn)的功能也有很多,比如:
1)學生類中有一個方法是繳費,也有一個方法是注冊,這兩個方法應該關(guān)聯(lián)起來,繳費成功后,才可以進行注冊
2)每個老師應該可以通過各種方式來查看自己學生的信息,比如按照姓名,學號等等
3)每個學生都應該可以查看學校所有的課程和教師情況
4)所有的這些信息必須保存在文件或者數(shù)據(jù)庫中才可以得到永久的保存
5)在客戶上傳相應的數(shù)據(jù)時,應該對其有所約束,比如說學號必須是10位正整數(shù)(在這里,為了避免報錯,將所有的數(shù)據(jù)都設(shè)置為字符串型)
6)講師,學生和課程的刪除,修改,查詢等操作需要添加
7)各類對象在初始化的時候需要輸入的信息太多,應該做成只需要唯一ID和PASSWD這種類型的來進行相應的登錄
8)等等
二、程序代碼
#!/usr/bin/env python #coding:utf-8 """ file:Management.py date:9/9/179:57 PM author:hx desc:管理系統(tǒng)雛形 """ ##添加模塊 import sys import json ##學校類定義 class School(object): ##初始化函數(shù) def __init__(self,SchoolName,SchoolPlace,SchoolMotto): self.SchoolName = SchoolName self.SchoolPlace = SchoolPlace self.SchoolMotto = SchoolMotto ##招生函數(shù) def RecruitStu(self): NewStuName = raw_input("StuName:") NewStuAge = raw_input("StuAge:") NewStuSex = raw_input("StuSex:") NewStuSchool = raw_input("StuSchool:") CourseNo = raw_input("CourseNo:") NewStuID = raw_input("StuID:") CoursePrice = raw_input("CoursePrice:") NewStu = Stu(NewStuName,NewStuAge,NewStuSex,NewStuSchool,CourseNo,NewStuID,CoursePrice) ##實例化學員對象 stus_dict = {"StuName":NewStuName,"StuAge":NewStuAge,"StuSex":NewStuSex,"StuSchool":NewStuSchool,"CourseNo":CourseNo,"StuID":NewStuID,"CoursePrice":CoursePrice} # 用字典來存放講師信息 if not dic: dic[NewStuName] = stus_dict json.dump(dic, open("student_db", "w"), encoding='utf-8', ensure_ascii=False, indent=2) else: if dic.get(NewStuName): print("%s學生已存在,不能注冊名字相同的學生" % NewStuName) else: dic[NewStuName] = stus_dict json.dump(dic, open("student_db", "w"),encoding='utf-8', ensure_ascii=False, indent=2) print("The student has already added successfully".center(50, '-')) NewStu.StuInfo() ##聘請講師 def HireTch(self): print "Welcome to hire teacher from here~" NewTeacherName = raw_input("Please input the teacher's name:") NewTeacherAge = raw_input("Please input the teacher's age:") NewTeacherSex = raw_input("Please input the teacher's sex:") NewCourseNo = raw_input("Please input the teacher's course number:") NewSalary = raw_input("Please input the teacher's salary:") NewTeacher = Teacher(NewTeacherName, NewTeacherAge, NewTeacherSex, NewCourseNo,NewSalary) # 實例化講師對象 teachers_dict = {"TeacherName":NewTeacherName,"TeacherAge":NewTeacherAge,"TeacherSex":NewTeacherSex,"CourseNo":NewCourseNo,"Salary":NewSalary} # 用字典來存放講師信息 # 通過json將講師的字典反序列化到dic字典中 if not dic: #字典如果為空 dic[NewTeacherName] = teachers_dict #將講師名與講師對象相關(guān)聯(lián) # 通過json將講師的字典序列化到teacher_db文件中 json.dump(dic, open("teacher_db", "w"),encoding='utf-8',ensure_ascii=False,indent=2) else: #如果文件中已有講師信息 if dic.get(NewTeacherName): #字典中不存在key,則返回none,不報錯 print("%s講師已存在,不能創(chuàng)建名字相同的講師" % NewTeacherName) else: dic[NewTeacherName] = teachers_dict json.dump(dic, open("teacher_db", "w"),encoding='utf-8',ensure_ascii=False,indent=2) NewTeacher.TeacherInfo() ##將新老師的信息打印在屏幕上 ##新增課程 def CreateCourse(self): print "Welcome to create course!" NewCourseNo = raw_input("CourseNo:") NewCourseName = raw_input("CourseName:") NewCoursePrice = raw_input("CoursePrice:") NewCourse = Course(NewCourseNo,NewCourseName,NewCoursePrice) ##新創(chuàng)建的對象直接實例化 courses_dict = {"CourseNo":NewCourseNo,"CourseName":NewCourseName,"CoursePrice":NewCoursePrice} # 用字典來存放講師信息 if not dic: dic[NewCourseNo] = courses_dict json.dump(dic, open("course_db", "w"), encoding='utf-8', ensure_ascii=False, indent=2) else: if dic.get(NewCourseNo): print("%s課程已存在,不能注冊課程號相同的課程" % NewCourseNo) else: dic[NewCourseNo] = courses_dict json.dump(dic, open("course_db", "w"),encoding='utf-8', ensure_ascii=False, indent=2) print("Course has already created successfully".center(50, '-')) print (""" CourseNo:%s CourseName:%s CoursePrice:%s"""%(NewCourseNo,NewCourseName,NewCoursePrice)) class Teacher(object): def __init__(self, TeacherName, TeacherAge, TeacherSex, CourseNo, Salary): self.TeacherName = TeacherName self.TeacherAge = TeacherAge self.TeacherSex = TeacherSex self.CourseNo = CourseNo self.Salary = Salary def TeachKnowledge(self): print "Teach Knowlege~" def TeacherInfo(self): print(""" -------------講師信息------------- Name:%s Age:%s Sex:%s CourseNo:%s Salary:%s """ % (self.TeacherName, self.TeacherAge,self.TeacherSex, self.CourseNo, self.Salary)) ##課程類定義 class Course(object): def __init__(self,CourseNo,CourseName,CoursePrice): self.CourseNo = CourseNo self.CourseName = CourseName self.CoursePrice = CoursePrice def ShowCourseInfo(self): print (""" CourseNO:%s CourseName:%s CoursePrice:%s""" %(self.CourseNo,self.CourseName,self.CoursePrice)) ##學員類定義 class Stu(object): def __init__(self,StuName,StuAge,StuSex,StuSchool,CourseNo,StuID,CoursePrice): self.StuName = StuName self.StuAge = StuAge self.StuSex = StuSex self.StuSchool = StuSchool self.CourseNo = CourseNo self.StuID = StuID self.CoursePrice = CoursePrice def Study(self): print "study" def PayMoney(self): print "Paying for money~" def StuInfo(self): print(""" ---------------學生信息-------------- Name:%s Age:%s Sex:%s School:%s CourseNo:%s ID:%s CoursePrice:%s """ %(self.StuName,self.StuAge,self.StuSex,self.StuSchool,self.CourseNo,self.StuID,self.CoursePrice)) def students_view(): # 學員視圖 while True: pro = """ 1.歡迎注冊 2.返回 3.退出 請選擇: """ num = raw_input(pro) if num == '1': choice_school_obj.RecruitStu() # 調(diào)用學生注冊方法并生成學生對象 elif num == '2': break elif num == '3': sys.exit() else: continue def teacher_view(): # 講師視圖 name = raw_input("請輸入講師姓名:") while True: if dic.get(name) or teachers_dict.get(name): print("歡迎%s講師".center(50, '-') % name) elif not dic.get(name) and not teachers_dict.get(name): print("%s講師不存在" % name) break pro = """ 1.查看學員信息 2.返回 3.退出 請輸入你的選擇: """ num = raw_input(pro) if num == '1': if teachers_dict.get(name): teachers_dict[name].show_student() # 查看學生信息 else: print("功能未完善,只能輸入lvah,cheng") elif num == '2': break elif num == '3': sys.exit() else: continue def school_view(): # 學校視圖 while True: pro = """ 1.創(chuàng)建課程 2.招生注冊 3.聘用講師 4.返回 5.退出 請輸入你的選擇: """ num = raw_input(pro) if num == '1': choice_school_obj.CreateCourse() elif num == '2': choice_school_obj.RecruitStu() elif num == '3': choice_school_obj.HireTch() elif num == '4': break elif num == '5': sys.exit() else: continue def main(): global dic # 全局變量 global choice_school_obj dic = {} while True: print("請選擇學校".center(50, '*')) pro1 = """ 1. %s 2. %s 3. 返回 4. 退出 請輸入你的選擇: """ % (school1.SchoolName, school2.SchoolName) choice_school = raw_input(pro1) if choice_school == '1': choice_school_obj = school1 # 將對象引用傳給choice_school elif choice_school == '2': choice_school_obj = school2 elif choice_school == '3': break elif choice_school == '4': sys.exit() else: continue while True: print("請選擇視圖".center(50, '*')) pro2 = """ 1.學員視圖 2.講師視圖 3.學校管理視圖 4.返回 5.退出 請選擇視圖: """ num = raw_input(pro2) if num == '1': print("歡迎進入學員視圖".center(50, '*')) students_view() elif num == '2': print("歡迎進入講師視圖".center(50, '*')) teacher_view() elif num == '3': print("歡迎進入學校管理視圖".center(50, '*')) school_view() elif num == '4': break elif num == '5': sys.exit() else: continue if __name__ == '__main__': teachers_dict = {} courses_dict = {} stus_dict = {} school1 = School("A大學", "曲江校區(qū)", "祖國、榮譽、責任") # 實例化兩個學校 school2 = School("B大學", "長安區(qū)", "愛國、求是、奮進") t1 = Teacher("leo", "28", "male", "01", "10000") t2 = Teacher("harry", "26", "female", "02", "9000") # 實例化兩個講師 teachers_dict["leo"] = t1 teachers_dict["harry"] = t2 teacher_dict = {"TeacherName": "leo", "TeacherAge": "28", "TeacherSex": "male", "CourseNo": "01", "Salary": "10000"} teacher_dict = {"TeacherName": "harry", "TeacherAge": "26", "TeacherSex": "female", "CourseNo": "02","Salary": "9000"} course1 = Course("01", "Linux云自動化運維", "12800") # 實例化兩個課程 course2 = Course("02", "c/c++開發(fā)", "9800") courses_dict["01"] = course1 courses_dict["02"] = course2 courses_dict = {"CourseNo":"01","CourseName":"Linux云自動化運維","CoursePrice":"12800"} courses_dict = {"CourseNo": "02", "CourseName": "c/c++開發(fā)", "CoursePrice": "9800"} stu1 = Stu("Katy","18","female","A大學","01","3150911026","12800") ##實例化兩個學員 stu2 = Stu("Betty","18","male","B大學","02","3150911022","12000") stus_dict["Katy"] = stu1 stus_dict["Betty"] = stu2 stu_dict = {"StuName":"Katy","StuAge":"18","StuSex":"female","StuSchool":"A大學","CourseNo":"01","StuID":"3150911026","CoursePrice":"12800"} stu_dict = {"StuName":"Betty","StuAge":"18","StuSex":"male","StuSchool":"B大學","CourseNo":"02","StuID":"3150911022","CoursePrice":"12000"} print(school1, school2) main()
三、運行結(jié)果
感謝你能夠認真閱讀完這篇文章,希望小編分享的“Python如何實現(xiàn)學校管理系統(tǒng)”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計公司,關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計公司行業(yè)資訊頻道,更多相關(guān)知識等著你來學習!
另外有需要云服務器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、網(wǎng)站設(shè)計器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。
新聞標題:Python如何實現(xiàn)學校管理系統(tǒng)-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://jinyejixie.com/article2/peoic.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)頁設(shè)計公司、網(wǎng)站制作、移動網(wǎng)站建設(shè)、軟件開發(fā)、網(wǎng)站收錄、定制開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容