开发者社区> 问答> 正文

python中hash函数执行报错

import hashlib
pwd = "aaa" + chr(163) + "cd"
checkcode = hashlib.md5(pwd).hexdigest()
print (checkcode)

运行报错

Traceback (most recent call last):
  File "/Users/jiangyd/PycharmProjects/untitled16/b.py", line 55, in <module>
    checkcode = hashlib.md5(pwd).hexdigest()
TypeError: Unicode-objects must be encoded before hashing

展开
收起
水果黄瓜 2021-10-24 12:37:09 443 0
0 条回答
写回答
取消 提交回答
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载