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 165 views
1 answer 248 views
1 answer 309 views
1 answer 269 views
...