How to convert a bytearray to a hexadecimal string using Python

2 Answers

0 votes
barr = bytearray([15, 255, 100, 56])

hex_string = barr.hex()

print(hex_string)



"""
run:

0fff6438

"""

 



answered Jan 8 by avibootz
0 votes
import binascii

barr = bytearray([15, 255, 100, 56])

hex_string = binascii.hexlify(barr).decode()

print(hex_string)



"""
run:

0fff6438

"""

 



answered Jan 8 by avibootz

Related questions

1 answer 275 views
1 answer 368 views
1 answer 424 views
1 answer 373 views
...