直接复制粘贴就能运行,如果报错导入一下datetime包
应付作业用的所以代码写的的比较乱,应付作业的话直接复制就好了
import datetime as datetime
teacher_list = [] # 教师列表
student_list = [] # 学生列表
login_teacher = "" # 当前登录教师
admin_password = "" # 管理员密码
# 目录类
class PrintTxt:
time = ""
now_time = ""
def __init__(self):
now = datetime.datetime.now()
self.now_time = "日期: "+ now.strftime("%Y{}%m{}%d{}%H{}%M{}")\
.format("年","月","日","时","分")
now_time = now.strftime("%H")
now_time=int(now_time)
if now_time>0 and now_time<=6:
self.time = "深夜了!"
elif now_time >6 and now_time<=8:
self.time = "早上好!"
elif now_time >8 and now_time<=12:
self.time = "上午好!"
elif now_time >12 and now_time<=14:
self.time = "中午好!"
elif now_time >14 and now_time<=18:
self.time = "下午好!"
else:
self.time = "晚上好!"
print("学生管理系统:")
def mulu(self):
"""打印分割线"""
print("-" * 50)
print("%s 欢迎使用学生管理系统--登录页面!\n\n1.教师登录\n"
"2.教师注册\n3.教师列表\n4.教师修改\n5.教师删除\n\n0.退出系统\n\n%s" % (self.time,self.now_time))
print("-" * 50)
def student_mulu(self, username):
"""打印分割线"""
print("-" * 50)
print("%s 欢迎使用学生管理系统--学生管理页面--当前登录用户:"
" %s \n\n1.学生列表\n2.新建学生\n3.修改学生\n4.删除学生\n\n0.返回上一页面\n\n%s" % (self.time,username,self.now_time))
print("-" * 50)
def teacher_list(self):
print("-" * 50)
print("账号\t|\t密码\t|\t教师名\t|\t创建时间\n")
for teacher in teacher_list:
print("%s\t|\t%s\t|\t%s\t|%s" % (
teacher.username, teacher.password, teacher.teacher_name, teacher.create_time))
print("-" * 50)