2018-01-13 python python hashlib md5 unicodeEncodeError 1234567string = "beyongjie"md5 = hashlib.md5()md5.update(string.encode('utf-8')) #注意转码res = md5.hexdigest()print("md5加密结果:",res) 正常直接计算Unicode就行,但如果报编码错误,可以尝试计算str 参考 Newer mongodb compact disk space Older python from __future__ import absolute_import