如何在python中比较unicode和string

2024-09-29 23:20:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试在用字符串编码base64之后比较值。但是encode64不等于Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=为什么不等于?你知道吗

import hashlib
hash_object = hashlib.sha256(b'Test')
hex_dig = hash_object.hexdigest()
encode64 = hex_dig.decode('hex').encode('base64')
print(encode64)
if encode64 == 'Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=' :
    print("Hello")

输出

Uy6qvZV0iA2/drm4zACDLCCm7BE9aCKZVQ16bg80XiU=

它不打印Hello。你知道吗


Tags: 字符串importhello编码objecthashhashlibprint

热门问题