#模拟用户的登录
#用户 输入用户名
#用户输入 密码
#明文密码进行摘要 拿到一个密文的密码
#写入文件
#用户的登录
import hashlib
user = input("username:")
psd = input('password:')
with open(r'D:python再学习day28file','r',encoding='utf-8') as f:
for line in f:
username,password,role = line.split('|')
md5 = hashlib.md5()
md5.update(bytes(psd,encoding='utf8'))#md5.update()里面要是bytes()类型才行
md5_psd = md5.hexdigest()
if username == user and md5_psd == password:
print('登录成功!')