>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')
I have a HexBytes object hb
.
I want to get 0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178
string, what should I do?
>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')
I have a HexBytes object hb
.
I want to get 0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178
string, what should I do?
never worked with this module but this should do the job:
hexdecimal = "".join(["{:02X}".format(b) for b in hb])
.hex()
does not work anymore with hexbytes >= 1.0
It reverts to parent class behaviour.
Now you should use the method .to_0x_hex()
.
I just debugged this on a new build of our software which pulls in a library that pulls in hexbytes. The latest version of the library we use has actually fixed the requirement for hexbytes to be <0.4 (latest before 1.0 is 0.3.1) i assume because of this. Unfortunately we do not use that yet :)
© 2022 - 2024 — McMap. All rights reserved.