Paul Bernard
Paul Bernard

Reputation: 1

Hex value converts to wrong code in Python

I'm trying to use Python to send Byte stream commands to an RFID Module.

The device requires an example command:

b'\xa0\x06\x01\x72'

When I save this and print it to the console, it shows instead as:

b'\xa0\x06\x01r'

I've tried using multiple functions but all return the same:

>>> bytearray(b'x72')
'r'

>>> btyes.fromhex('72')
'r'

>>> array.array('B', [114]).tobytes()
'r'

All hex codes from 0x01-0x7F are shown to ASCII characters when executing the code.

Is it possible to force Python to display and therefore send the actual hex value?

Upvotes: 0

Views: 40

Answers (0)

Related Questions