TypeError: Unicode-objects must be encoded before hashing

python3中md5报错

>>> import hashlib
>>> md5 = hashlib.md5()
>>> md5.update("123")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Unicode-objects must be encoded before hashing

  • 正确方法

python3中字符对象是unicode对象,不能直接加密

md5.update("123".encode("utf-8"))

《寿康宝鉴》有声书
寿康宝鉴百话有声书(mp3)



posted @ 2018-06-29 07:14  妙音  阅读(5956)  评论(0编辑  收藏  举报