import hashlib def get_md5(): obj = hashlib.md5('iuqe832643873gh'.encode('utf-8')) obj.update(data.encode('utf-8')) result = obj.hexdigest() return result USER_LIST = [] def enroll(): print('************用戶注冊************') while True: user = input('請輸入用戶名:') if user == 'N': return pwd = input('請輸入密碼:') temp = {'username': user, 'password': get_md5(pwd)} USER_LIST.append(temp) def login(): print('************用戶登陸************') user = input('請輸入用戶名:') pwd = input('請輸入密碼') for obj in USER_LIST: if obj['username'] == user and obj['password'] == get_md5(pwd): return True enroll() result = login() if result: print('登陸成功!') else: print('登陸失敗!')