TypeError: Unicode-objects must be encoded before hashing

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/wyongqing/article/details/80851268

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)
百度网盘  https://pan.baidu.com/s/1rs5k7RTB9DxgdCuG-mSzog  密码 9lf1



猜你喜欢

转载自blog.csdn.net/wyongqing/article/details/80851268
今日推荐