How to convert hex string to bytes

Ayush

I have a hex string:

53 9B 33 3B 39 70 6D 14 90 28 CF E1 D9 D4 A4 07

I have the following code:

from binascii import unhexlify  
data = unhexlify(b'53 9B 33 3B 39 70 6D 14 90 28 CF E1 D9 D4 A4 07')

But it throws the following error binascii.Error: Odd-length string

Lior Cohen

You have spaces in your argument.

from binascii import unhexlify    
data = unhexlify(b'539B333B39706D149028CFE1D9D4A407')
print(data)  # --> b'S\x9b3;9pm\x14\x90(\xcf\xe1\xd9\xd4\xa4\x07'

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related