import hashlib hash = hashlib.md5() hash.update('asdasd'.encoding('utf8')) # 只能编码成utf8才行 print(hash.hexdigest())