【发布时间】:2021-08-29 09:28:48
【问题描述】:
我有这个字节串:
output1 = 'fef00a01'
我正在尝试将其转换为字节:
output2 = b'\xfe\xf0\n\x01'
这不满足条件:
output1 == output2 # <--- returns False
如何让它返回 True?
【问题讨论】:
-
output1是string类型,output2是bytes类型。你怎么能指望他们是平等的?另外,您能否详细说明您想要实现的目标。 -
我正在尝试将 output1 转换为 output2
-
你可以在 Python 中使用
bytes()函数将string转换为bytes。 BTWoutput2的编码是什么?
标签: python python-3.x binary