-1

我有以下脚本:

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

它打印/返回的问题None。我想知道,因为在这个例子中它有效。

提前致谢。

4

1 回答 1

3

我发现了这个问题。该方法.reverse()不返回任何内容,但会更改bytearray,因此代码必须是:

hex_string = "c23dba5fcac1048b3c050266ceb6a0e870670021"
hex_bytes = bytearray.fromhex(hex_raw)
hex_bytes.reverse()
print(hex_bytes)
于 2020-12-05T13:34:51.487 回答