1

I have a json with data="90ab"

unpack = json.loads(content)
data = unpack['data']
data_byte=bytearray.fromhex(data)

I want data_byte to be an array of bytes [byte1 byte2], with byte1=0x90, and byte2=0xab I need help, because what I tried doesn't seem to work Thanks

2

1 Answer 1

1

It depends on python version, so the way to decode hex data may vary:

data="90ab"

Since Python 2.7 and 3.0:

bytearray.fromhex(data)

Python 2.6 and before:

data.decode("hex")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.