python实现高校教务管理系统_python+mysql实现教务管理系统
本文实例为大家分享了python实现教务管理系统,供大家参考,具体内容如下
mysql+python构成教务管理系统,提供系统管理员,教职工,学生三级。有注册,添加,修改,发布信息等功能。
Login.py
#-*- coding:utf-8 -*-
#####系统登录
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 -*-
####系统入口
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 -*-
####学生账号
import MySQLdb
import os
class Student:
def __init__(self,conn,account,passwd):
###构造,conn连接数据库
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):
###主要执行函数
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):
###个人信息
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):
###修改个人信息
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):
###查看详细消息, 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):
###个人信息界面
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()
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。
python实现高校教务管理系统_python+mysql实现教务管理系统相关推荐
- python登录教务系统_python+mysql实现教务管理系统
本文实例为大家分享了python实现教务管理系统,供大家参考,具体内容如下 mysql+python构成教务管理系统,提供系统管理员,教职工,学生三级.有注册,添加,修改,发布信息等功能. Login ...
- MySQL超市会员管理系统_PHP+MYSQL药店会员管理系统的设计与实现
药房会员管理系统是信息时代的产物,随着时代的发展,各大药店也与时俱进使用了各类现代化的系统来进行各类药品和会员信息的管理,甚至有些药店会给会员使用积分系统,根据用户的消费进行积分,然后用积分兑换一些差 ...
- python做数据库管理系统_python+mysql做一个图书管理系统?
开发一个图书管理系统,首先需要对此项目进行一个简单的需求分析: 主要功能包括:图书信息 图书分类 用户信息 用户借阅统计 管理员 管理员权限 接下来可以进行数据库的设计,在这里我提供一个简单的数据库表 ...
- 用python设计学生管理系统_python+tkinter实现学生管理系统
本文实例为大家分享了python+tkinter实现学生管理系统的具体代码,供大家参考,具体内容如下 from tkinter import * from tkinter.messagebox imp ...
- python车辆管理系统_Python简易版停车管理系统
本文实例为大家分享了Python简易版停车管理系统的具体代码,供大家参考,具体内容如下 import time # 最大停车数 max_car = 100 # 当前停车数,初始为0 cur_car = ...
- python销售管理系统_python实现手机销售管理系统
本文实例为大家分享了python实现手机销售管理系统的具体代码,供大家参考,具体内容如下 要求如下: 手机销售系统 手机品牌 手机价格 库存数量 vivoX9 2798 25 iphone7(32G) ...
- python数据库自动重连_python mysql断开重连的实现方法
后台服务在运行时发现一个问题,运行约15分钟后,接口请求报错 pymysql.err.InterfaceError: (0, '') 这个错误提示一般发生在将None赋给多个值,定位问题时发现 pym ...
- 图书管理系统python代码课程设计报告_python代码实现图书管理系统
本文实例为大家分享了python代码实现图书管理系统的具体代码,供大家参考,具体内容如下 图书管理系统 功能简介 添加图书时,图书ID不能重复,图书名可重复 删除,查询,修改功能,输入图书名之后提供所 ...
- python名片管理器实验步骤_Python综合应用名片管理系统案例详解
本文实例讲述了python综合应用名片管理系统.分享给大家供大家参考,具体如下: 综合应用已经学习过的知识点: 变量 流程控制 函数 模块 开发 名片管理系统 系统需求 程序启动,显示名片管理系统欢迎 ...
最新文章
- python twisted教程_Python Twisted系列教程16:Twisted 进程守护
- win10无法连接wifi_手机连接WIFI但是无法上网?3个办法帮您解决!
- 计算机网络基础:ISO/OSI网络体系结构知识笔记​
- mac mysql php_Mac搭建php开发环境:Apache+php+MySql
- php中接口验证失败,支付宝手机接口,服务端PHP验证失败,求助
- 4027-计数排序(C++,附解析)
- 学会学习比学习什么更重要
- dubbo2.6源码-负载均衡
- unity3d在Android端读取修改Json数据
- 我们精心整理的2019最新全栈资料!首次公布
- 【C/C++】C++运算符优先级
- 通过Downward API传递pod元数据
- 嵌入式linux软件/驱动开发工程师需要哪些知识
- 玉禾田环境金蝶云ERP操作手册
- 小米的过去、现在和未来
- 单片机c语言必背代码_stm32单片机编程用库函数好还是寄存器好?
- NewLand手持设备上条码扫描
- html在线排版编辑工具,html+css+js开发文本编辑器,有各种排版功能!
- 电子书籍检索下载很好的网站推荐
- python数据分析与展示--图像的手绘效果
热门文章
- linux磁盘空间不足,但是使用df却发现磁盘空间至少有一半的空间没有使用
- C语身教程第七章:布局与联结(5)
- sdcms的模板解析引擎,一个非常简单和实用的CMS
- linux 下,解决tomcat服务器接收中文乱码的问题
- java.sql.SQLException: Column ‘class‘ not found.异常没有找到列
- 出现java.lang.IllegalArgumentException异常
- 解决 Android 中出现依赖多个版本支持库的问题
- (五)stm32工程代码HardFault异常查错调试方法
- Joda-Time中两个日期之间的天数
- 人工神经网络相对于支持向量机有什么优势? [关闭]