问题 hashlib.sha3_512(file_path).hexdigest() 原因 hashlib这个库只接收byte数组数据,所以,将string变量转成byte数组即可。 解决 hashlib.sha3_512(file_path.encode("utf-8")).hexdigest() 参考: hashlib — Secure hashes and message digestsHow to correct TypeError: Unicode-objects must be encoded before hashing?hashlib使用时出现: Unicode-objects must be encoded before hashingBest way to convert string to bytes in Python 3?