24
>>> from hexbytes import HexBytes
>>> ...
>>> hb
HexBytes('0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178')

I have a HexBytes object hb.

I want to get 0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178 string, what should I do?

TylerH
  • 20,799
  • 66
  • 75
  • 101
Duoduo
  • 479
  • 1
  • 4
  • 10

2 Answers2

50

You can just type hb.hex() and it should work

jatinshah
  • 633
  • 7
  • 7
1

never worked with this module but this should do the job:

hexdecimal = "".join(["{:02X}".format(b) for b in hb])
J. Maatkamp
  • 21
  • 1
  • 4