最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

python+mysql實(shí)現(xiàn)教務(wù)管理系統(tǒng)

 更新時(shí)間:2019年02月20日 17:17:54   作者:ShellMeShell丶  
這篇文章主要為大家詳細(xì)介紹了python+mysql實(shí)現(xiàn)教務(wù)管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了python實(shí)現(xiàn)教務(wù)管理系統(tǒng),供大家參考,具體內(nèi)容如下

mysql+python構(gòu)成教務(wù)管理系統(tǒng),提供系統(tǒng)管理員,教職工,學(xué)生三級。有注冊,添加,修改,發(fā)布信息等功能。

Login.py

#-*- coding:utf-8 -*-
#####系統(tǒng)登錄

import os
import MySQLdb
import time

class Login:
 def __init__(self,conn):
 self.account = ''
 self.password = ''
 self.level = 2
 self.conn = conn
 
 def LoginSurface(self,info):
 os.system('cls')
 width = 50
 title = 'LOGIN'
 body1 = '[A]Admin'
 body2 = '[T]Teacher'
 body3 = '[S]Student'
 body4 = '[Q]Quit'
 print '=' * width
 print ' ' * ((width-len(title))/2), title
 print ' ' * ((width-len(body1))/2),body1
 print ' ' * ((width-len(body1))/2),body2
 print ' ' * ((width-len(body1))/2),body3
 print ' ' * ((width-len(body1))/2),body4
 print ' ' * ((width-len(info))/2), info
 print '-' * width
 
 def MainFunc(self):
 err = ''
 while True:
 self.LoginSurface(err)
 level = raw_input('Access:')
 level = level.upper()
 if level == 'A':self.level = 0
 elif level == 'T': self.level = 1
 elif level == 'S': self.level = 2 
 elif level =='Q': return False
 else : 
 err = 'Error Action!'
 continue
 self.account = raw_input('Account:')
 self.password = raw_input('Password:')
 if self.CheckAccount():
 err = 'Login Success!'
 self.LoginSurface(err)
 print 'Please wait...'
 time.sleep(3)
 return True;
 else :
 err = 'Login Failed!'
 def GetLoginAccount(self):
 return [self.account,self.password,self.level]
 
 def CheckAccount(self):
 cur = self.conn.cursor()
 sqlcmd = "select Account,Password,AccountLevel from LoginAccount where Account = '%s'" % self.account
 if cur.execute(sqlcmd) == 0: return False
 temp = cur.fetchone()
 cur.close()
 if temp[1] == self.password and temp[2] == self.level:
 return True
 else: return False
 
 def Quit(self):
 pass
 
if __name__ == '__main__':
 conn = MySQLdb.connect(user='root',passwd = '123456',db = 'test');
 a = Login(conn)
 a.MainFunc()
 a.Quit()
 conn.close()

main.py

#-*- coding:utf-8 -*-
####系統(tǒng)入口

import os
import MySQLdb
import Student
import Teacher
import Login
import SystemManager

if __name__ == '__main__':
 conn = MySQLdb.connect(user='root',passwd = '123456',db = 'test')
 log = Login.Login(conn)
 if log.MainFunc():
 account = log.GetLoginAccount()
 if account[2] == 0:
 usr = SystemManager.SystemManager(conn,account[0],account[1])
 usr.MainFunc()
 elif account[2] == 1:
 usr = Teacher.Teacher(conn,account[0],account[1])
 usr.MainFunc()
 elif account[2] == 2:
 usr = Student.Student(conn,account[0],account[1])
 usr.MainFunc()
 else : 
 conn.close()
 raise exception()
 conn.close()

Student.py

#-*- coding:utf-8 -*-
####學(xué)生賬號

import MySQLdb
import os

class Student:
 def __init__(self,conn,account,passwd): 
 ###構(gòu)造,conn連接數(shù)據(jù)庫
 cur = conn.cursor()
 sqlcmd = "select Name,Gender,Birth,Academy,Major,Grade,TeacherNo from StudentInfo where StudentNo = '%s'" % account
 cur.execute(sqlcmd)
 res = cur.fetchone()
 sqlcmd = "select Name from TeacherInfo where TeacherNo = '%s'" % res[6]
 cur.execute(sqlcmd)
 TeacherName = cur.fetchone()
 cur.close()
 
 self.width = 150
 self.conn = conn
 self.account = account
 self.Password= passwd
 self.Name = res[0]
 self.Gender = res[1]
 self.Birth = res[2]
 self.Accademy= res[3]
 self.Major = res[4]
 self.Grade = res[5]
 self.Teacher = TeacherName[0]
 
 def MainFunc(self):
 ###主要執(zhí)行函數(shù)
 info = ''
 while True:
 self.MainSurface(info)
 choice = raw_input('What to do?')
 choice = choice.upper()
 if choice != 'P' and choice != 'M' and choice != 'Q':
 info = 'Error Action!'
 continue
 if choice == 'P':
 info = self.PersonalInfo()
 elif choice == 'M':
 info = self.OperatMessage()
 else : break
 
 def PersonalInfo(self):
 ###個(gè)人信息
 info = ''
 while True:
 self.PersonalInfoSurface(info)
 choice = raw_input('What to do?')
 choice = choice.upper()
 if choice != 'C' and choice != 'Q':
 info = 'Error Action!'
 continue
 if choice == 'C':
 info = self.ChangePersonalInfo()
 else : break
 return info
 
 def ChangePersonalInfo(self):
 ###修改個(gè)人信息
 NewGender = self.Gender
 NewBirth = self.Birth
 NewPw = self.Password
 while True:
 choice = raw_input('Change Gender?(y/n)')
 choice = choice.lower()
 if choice == 'y':
 NewGender = raw_input('New Gender:')
 break
 elif choice == 'n': break
 else : pass
 while True:
 choice = raw_input('change Born Date?(y/n)')
 choice = choice.lower()
 if choice == 'y':
 NewBirth = raw_input('New Born Date:')
 break
 elif choice == 'n': break
 else : pass
 while True:
 choice = raw_input('change Password?(y/n)')
 choice = choice.lower()
 if choice == 'y':
 NewPw = raw_input('New Password:')
 break
 elif choice == 'n': break
 else : pass
 info = 'Change Success!'
 cur = self.conn.cursor()
 if NewGender != self.Gender or NewBirth != self.Birth:
 sqlcmd = "update StudentInfo set Gender = '%s',Birth = '%s' where StudentNo = '%s'" % (NewGender,NewBirth,self.account)
 if cur.execute(sqlcmd) == 0:
 self.conn.rollback()
 cur.close()
 return 'Change Fail!'
 if NewPw != self.Password:
 sqlcmd = "update LoginAccount set Password = '%s' where Account='%s'" % (NewPw,self.account)
 if cur.execute(sqlcmd) == 0:
 self.conn.rollback()
 cur.close()
 return 'Change Fail!'
 else :
 self.conn.commit()
 self.Gender = NewGender
 self.Birth = NewBirth
 self.Password = NewPw
 cur.close()
 return 'Change Success!'
 
 def OperatMessage(self):
 info = ''
 while True:
 self.MessageSurface(info)
 self.MessageList()
 choice = raw_input('What to do?')
 choice = choice.upper()
 if choice == 'M':
 msg = input('Message Id:')
 info = self.MessageInfo(msg)
 elif choice == 'Q': break;
 else : info = 'Error Action!'
 return info
 
 def MessageList(self):
 ###查看消息列表
 cur = self.conn.cursor()
 print ''
 sqlcmd = "select Id,SenderName,SendTime,Title from AllMessage where statu = 'pass' and MsgLevel = 1"
 if cur.execute(sqlcmd) == 0: return 
 print '-' * self.width
 while True:
 temp = cur.fetchone()
 if not temp: break;
 print '%3d%-20s%-50s%s' % (temp[0],temp[1],temp[3],temp[2])
 print '-' * self.width
 cur.close()
 
 def MessageInfo(self,MsgNo):
 ###查看詳細(xì)消息, No消息編號
 cur = self.conn.cursor()
 sqlcmd = "select SenderName,SendTime,Title,Content from AllMessage where Id = %d" % MsgNo
 if cur.execute(sqlcmd) == 0:
 cur.close()
 return 'Read Fail!'
 article = cur.fetchone()
 cur.close()
 os.system('cls')
 print '=' * self.width
 print ' ' * ((self.width - len(article[2]))/2) , article[2]
 head = article[0] + '  ' + str(article[1])
 print ' ' * ((self.width - len(head))/2) , head
 print '-' * self.width
 print article[3]
 print '=' * self.width
 raw_input('Press any key to return!')
 return ''
 
 def Quit(self):
 ###退出
 pass
 
 def MainSurface(self,info):
 ###主界面
 os.system('cls')
 print '=' * self.width
 title = 'Welcome %s!' % self.Name
 body1 = '[P]Personal Information'
 body2 = '[M]Message'
 body3 = '[Q]Quit'
 print ' ' * ((self.width - len(title))/2),title
 print ' ' * ((self.width - len(body1))/2),body1
 print ' ' * ((self.width - len(body1))/2),body2
 print ' ' * ((self.width - len(body1))/2),body3
 print ' ' * ((self.width - len(info))/2),info
 print '=' * self.width
 
 def MessageSurface(self,info):
 ###消息界面
 os.system('cls')
 print '=' * self.width
 title = 'MESSAGES'
 body1 = '[M]Message Detail'
 body2 = '[Q]Quit'
 print ' ' * ((self.width - len(title))/2),title
 print ' ' * ((self.width - len(body1))/2),body1
 print ' ' * ((self.width - len(body1))/2),body2
 print ' ' * ((self.width - len(info))/2),info
 print '=' * self.width
 
 def PersonalInfoSurface(self,info):
 ###個(gè)人信息界面
 os.system('cls')
 print '=' * self.width
 title = 'PERSONAL INFORMATION'
 body1 = '[C]Change Information'
 body2 = '[Q]Quit'
 print ' ' * ((self.width - len(title))/2),title
 print ' ' * ((self.width - len(body1))/2),body1
 print ' ' * ((self.width - len(body1))/2),body2
 print ' ' * ((self.width - len(info))/2),info
 print '-' * self.width
 body3 = '   Name: %s' % self.Name
 body4 = 'Student Number: %s' % self.account
 body5 = '  Gender: %s' % self.Gender
 body6 = '   Birth: %s' % self.Birth
 body7 = '  Accademy: %s' % self.Accademy
 body8 = '   Major: %s' % self.Major
 body9 = '   Grade: %s' % self.Grade
 body10= '  Teacher: %s' % self.Teacher
 print ' ' * ((self.width - len(body6))/2),body3
 print ' ' * ((self.width - len(body6))/2),body4
 print ' ' * ((self.width - len(body6))/2),body5
 print ' ' * ((self.width - len(body6))/2),body6
 print ' ' * ((self.width - len(body6))/2),body7
 print ' ' * ((self.width - len(body6))/2),body8
 print ' ' * ((self.width - len(body6))/2),body9
 print ' ' * ((self.width - len(body6))/2),body10
 print '=' * self.width
 
if __name__ == '__main__':
 conn = MySQLdb.connect(user='root',passwd = '123456',db = 'test')
 stu = Student(conn,'0000001','123456')
 stu.MainFunc()
 conn.close()

完整代碼請點(diǎn)擊下載:python實(shí)現(xiàn)教務(wù)管理系統(tǒng)

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。  

相關(guān)文章

  • Python爬蟲與反爬蟲大戰(zhàn)

    Python爬蟲與反爬蟲大戰(zhàn)

    這篇文章主要介紹了Python爬蟲與反爬蟲的相關(guān)資料,文中講解非常細(xì)致,幫助大家更好的理解Python爬蟲與反爬蟲的關(guān)系,感興趣的朋友可以了解下
    2020-07-07
  • Python快速從視頻中提取視頻幀的方法詳解

    Python快速從視頻中提取視頻幀的方法詳解

    本文為大家介紹一種從視頻中抽取視頻幀的方法,由于單線程抽取視頻幀速度較慢,因此這里我們增加了多線程的方法,感興趣的小伙伴可以動(dòng)手嘗試一下
    2022-07-07
  • 詳解python eval函數(shù)的妙用

    詳解python eval函數(shù)的妙用

    這篇文章主要介紹了詳解python eval函數(shù)的妙用,詳細(xì)介紹了python eval函數(shù)的具體用法和實(shí)例,有興趣的可以了解一下
    2017-11-11
  • 在PyTorch中自定義fit()函數(shù)中的操作代碼

    在PyTorch中自定義fit()函數(shù)中的操作代碼

    當(dāng)在進(jìn)行有監(jiān)督學(xué)習(xí)時(shí),我們可以使用fit()函數(shù)對模型進(jìn)行訓(xùn)練,通過迭代優(yōu)化模型的參數(shù),使其能夠更好地?cái)M合訓(xùn)練數(shù)據(jù),本文給大家介紹了在PyTorch中自定義fit()函數(shù)中的操作代碼,感興趣的同學(xué)可以跟著小編一起來看看
    2024-05-05
  • 在Python的Django框架下使用django-tagging的教程

    在Python的Django框架下使用django-tagging的教程

    這篇文章主要介紹了在Python的Django框架下使用django-tagging的教程,針對網(wǎng)絡(luò)編程中的tag部分功能提供幫助,需要的朋友可以參考下
    2015-05-05
  • Pyinstaller打包報(bào)錯(cuò)小結(jié)

    Pyinstaller打包報(bào)錯(cuò)小結(jié)

    本文主要介紹了Pyinstaller打包報(bào)錯(cuò)小結(jié),詳細(xì)的介紹了5種錯(cuò)誤的解決方法,文中通過示例代碼介紹的非常詳細(xì),需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2024-02-02
  • Python 函數(shù)裝飾器應(yīng)用教程

    Python 函數(shù)裝飾器應(yīng)用教程

    函數(shù)裝飾器是Python提供的一種增強(qiáng)函數(shù)功能的標(biāo)記函數(shù),本文將帶大家深入學(xué)習(xí)一下Python 函數(shù)裝飾器,感興趣的同學(xué)跟隨小編一起學(xué)習(xí)吧
    2021-12-12
  • 利用python代碼寫的12306訂票代碼

    利用python代碼寫的12306訂票代碼

    這篇文章主要介紹了利用python代碼寫的12306訂票代碼,自己寫的python代碼,是非常實(shí)用的技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下
    2015-12-12
  • python 異常處理總結(jié)

    python 異常處理總結(jié)

    這篇文章主要介紹了python 異常的相關(guān)資料,并整理了相關(guān)異常資料,需要的朋友可以參考下
    2016-10-10
  • Python集合pop()函數(shù)使用方法詳解

    Python集合pop()函數(shù)使用方法詳解

    這篇文章主要介紹了Python 集合 pop()函數(shù)的使用方法,文中有詳細(xì)的代碼實(shí)例,講解的非常清楚,具有一定的參考價(jià)值,需要的朋友可以參考下
    2023-07-07

最新評論

获嘉县| 从江县| 化德县| 册亨县| 饶平县| 穆棱市| 紫金县| 玛纳斯县| 松江区| 朝阳市| 阳曲县| 沙田区| 连江县| 莎车县| 黑河市| 广灵县| 广西| 邹城市| 志丹县| 南昌市| 隆昌县| 玉门市| 正宁县| 汉阴县| 广元市| 会宁县| 定安县| 广平县| 涿州市| 三都| 克什克腾旗| 资溪县| 股票| 江川县| 寿阳县| 娄烦县| 婺源县| 山西省| 宿州市| 蓬溪县| 德庆县|