def main(): # 存取所以用户的信息 # 界面对象 admin = Admin() admin.print_admin_view() # 用户管理员开机 # 如果view.admin_login()返回值是-1,程序结束。如果是0就不会执行下去 if admin.admin_option() == -1: return -1 # 提款机对象 ''' f = open(file_path, "rb") all_users = pickle.load(f) atm = Atm(all_users) ''' file_path = os.path.join(os.getcwd(), "a.txt") all_users = {} atm = Atm(all_users) # admin.print_sys_function_view() while True: admin.print_sys_function_view() # 等待用户操作 option = input("请输入你的操作:") if option == "1": atm.create_user() elif option == "2": atm.search_user_info() elif option == "3": atm.get_money() elif option == "4": print("存款") elif option == "5": print("转账") elif option == "6": print("改密") elif option == "7": atm.lock_user() elif option == "8": atm.unlock_user() elif option == "9": print("补卡") elif option == "0": print("销户") elif option == "q": if not admin.admin_option(): # 讲当前系统中用户信息保存到文件中 # abs_path = os.getcwdb() # 获取当前目录觉得路径 # file_path = os.path.join(os.getcwdb(), "allusers.txt") f = open(file_path, "wb") pickle.dump(atm.all_user, f) f.closed print(file_path) return -1 time.sleep(0.5)
def main(): # 界面对象 view = Admin() # 管理员开机 view.printAdminView() if not view.admin_option(): return -1 print("登录成功!请稍后") # 存储所有用户的信息 abs_path = os.getcwd() file_path = os.path.join(abs_path, "allusers.txt") with open(file_path, "rb") as f: all_user = pickle.load(f) ATM = Atm(all_user) view.printsysView() while True: # 等待用户操作 view.printsysView() option = input("请输入您的操作:") if option == "1": # 目标向用户字典中增加(卡号———用户) ATM.create_user() elif option == "2": ATM.search_user() elif option == "3": ATM.withdraws() elif option == "4": ATM.save_money() elif option == "5": ATM.transfer_money() elif option == "6": ATM.change_password() elif option == "7": ATM.lock_user() elif option == "8": ATM.unlock_user() elif option == "9": ATM.new_card() elif option == "0": print("销户") elif option == "q": if view.admin_option(): print("退出,成功") # 将当前系统中的文件保存进入文件中 with open(file_path, "wb") as f: pickle.dump(ATM.all_user, f) return True else: print("退出失败,请重新退出") time.sleep(1) elif option == "c": ATM.user_check() time.sleep(2)