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('登陆失败!')