1,文件夹解析:
2,内容:
2.1
import os # BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) BASE_DIR = "\".join(os.path.abspath(os.path.dirname(__file__)).split("\")[:-1]) database_path = os.path.join(BASE_DIR,"db") school_db_file = os.path.join(database_path,"school") from core import main if __name__ == '__main__': obj = main.Manage_center() obj.run()
2.2:前面strat,py 中写了 可以省略这一步
import os BASE_DIR = "\".join(os.path.abspath(os.path.dirname(__file__)).split("\")[:-1]) database_path = os.path.join(BASE_DIR,"db") school_db_file = os.path.join(database_path,"school")
2.3
import os import sys import shelve from conf import settings from modules.school import School '''装饰器登录验证''' auth_status = {'user': None,'status': False} def wrapper(func): def inner(*args, **kwargs): count = 1 while count <= 3: if auth_status['status']: ret = func(*args, **kwargs) # index/home ret None return ret else: # 获取用户名和密码 name = input('请输入你的用户名:').strip() pwd = input('请输入您的密码:').strip() # with open(text_f, 'r', encoding='utf-8') as f: # dic = eval(f.read()) # 读入文件 # if name in dic and pwd == dic[name]: # 判断输入的用户名和密码是否读入的文件中包含 if name=='fugui' and pwd=='123': print('登录成功!') auth_status['user'] = name auth_status['status'] = True ret = func(*args, **kwargs) return ret else: print('登录失败!') count += 1 return inner class Manage_center: # def __init__(self): # pass # @wrapper def run(self): while True: print(" 33[34;0m欢迎进入FG课程系统 33[0m " "1 学生视图 " "2 教师视图 " "3 学校管理视图 " "4 退出学员管理系统 ") user_choice = input("