def student_choice_read(obj_name): if obj_name == "School": obj_name = School elif obj_name == "Teacher": obj_name = Teacher else: obj_name = Course filenames = DB_handler.get_all_filename(obj_name.__name__.lower()) if not filenames: return False # 生成对象 obj_lis=[DB_handler.load_obj_from_file(obj_name.__name__.lower(), i)\ for i in filenames] return obj_lis
def login(startname): global Logging, name while True: username = input("请输入登录用户名:").strip() filenames = DB_handler.get_all_filename(startname.lower()) if username in filenames: pwd = input("请输入登录密码:").strip() obj1 = DB_handler.halib_file(pwd) obj = DB_handler.load_obj_from_file(startname, username) pwd2 = getattr(obj, "pwd") if obj1 == pwd2: Logging = True print("登录成功!!!") name = obj return name print("密码错误!!!") continue while True: if startname == "student" or startname == "admin": print(""" ====================== 1.注册 2.返回 ====================== """) choice = input("请选择:") if choice == "1": obj = register(startname) if not obj: return elif choice == "2": return else: print("输入错误!!!") else: print("请联系管理员帮你注册") return