尝试在 python 中反转字节数组(从十六进制)

Try to reverse an bytearray(from hex) in python

我有以下脚本:

hex_string = "c23dba5fcac1048b3c050266ceb6a0e870670021"
hex_bytes = bytearray.fromhex(hex_raw)
print(hex_bytes.reverse())

问题呢prints/returnsNone。我想知道,因为在 this 示例中它有效。

提前致谢。

我发现了问题。方法 .reverse() 没有 return 任何东西,但是改变了 bytearray,所以代码必须是:

hex_string = "c23dba5fcac1048b3c050266ceb6a0e870670021"
hex_bytes = bytearray.fromhex(hex_raw)
hex_bytes.reverse()
print(hex_bytes)