import hashlib def make_password(password): md5=hashlib.md5() # 实例化 md5.update(password.encode(encoding='utf-8')) # 对·字符转类型加密 encoding=utf-8 为默认的可不写 md5_server=md5.hexdigest() # 加密 return md5_server print(make_password('111'))