如何从 HexBytes 对象中获取十六进制字符串?
how to get hex string from a HexBytes object?
>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')
我有一个 HexBytes 对象 hb
,我想获取 '0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178' 字符串,我应该怎么做?
从未使用过此模块,但这应该可以完成工作:
hexdecimal = "".join(["{:02X}".format(b) for b in hb])
您只需输入 hb.hex()
就可以了
>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')
我有一个 HexBytes 对象 hb
,我想获取 '0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178' 字符串,我应该怎么做?
从未使用过此模块,但这应该可以完成工作:
hexdecimal = "".join(["{:02X}".format(b) for b in hb])
您只需输入 hb.hex()
就可以了