import hashlib
a = "81228"
m = hashlib.md5()
m.update(a.encode('utf-8'))
print(m.hexdigest())

 这里的参数必须为bytes类型

相关文章: