bartosz
bartosz

Reputation: 414

Understanding bytearray from hex

Why this there is so difference in output with printing bytearray?

While example 1 seems fine to me. I don't understand why output of example 2 isn't bytearray(b'\x2f')?

# example 1
print(bytearray.fromhex('1f'))
# output bytearray(b'\x1f')

# example 2
print(bytearray.fromhex('2f'))
# output: bytearray(b'/')

Upvotes: 0

Views: 100

Answers (1)

Scott Hunter
Scott Hunter

Reputation: 49813

Because 2f is the ASCII code for the character /.

Upvotes: 1

Related Questions