TypeError: Unicode-objects must be encoded before hashing

2018年6月29日 07:16

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

正确方式

unicode对象不能直接加密

md5.update("123".encode("utf-8"))
 
《寿康宝鉴》有声书
寿康宝鉴百话有声书(mp3)

 

Tags: python3
评论(15) 阅读(17983)

python3.6编码错误unable to load the file system codec

2018年6月02日 20:09

  • 情况描述
在windows中安装python、virtualenv后,启动cmd界面,使用virtualenv创建运行环境出现错误,意思是加载不了系统编码
 
c:\python36\Scripts\virtualenv.exe test
Fatal Python error: Py_Initialize: unable to load the file system codec
  • 解决办法
将cmd编码改为utf-8
chcp 65001
 

Tags: python3
评论(154) 阅读(18534)