python实现高校教务管理系统_python实现教务管理系统

#-*- 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 = '',db = 'DB_EducationalManagementSystem');

a = Login(conn)

a.MainFunc()

a.Quit()

conn.close()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值