Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get hex string from a HexBytes object?

Tags:

python

web3

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

I have a HexBytes object hb, I want get the '0x53b983fe73e16f6ed8178f6c0e0b91f23dc9dad4cb30d0831f178' string, what should I do?

like image 715
Duoduo Avatar asked May 24 '18 11:05

Duoduo


People also ask

How do you convert bytes to hexadecimal?

To convert byte array to a hex value, we loop through each byte in the array and use String 's format() . We use %02X to print two places ( 02 ) of Hexadecimal ( X ) value and store it in the string st .

How do you convert bytes to hex in python?

Use the hex() Method to Convert a Byte to Hex in Python The hex() method introduced from Python 3.5 converts it into a hexadecimal string. In this case, the argument will be of a byte data type to be converted into hex.

What is Hexbytes?

hexbytes: Python `bytes` subclass that decodes hex, with a readable console output.


1 Answers

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

like image 152
jatinshah Avatar answered Nov 02 '22 03:11

jatinshah