I am trying to send a hexadecimal string to a serial port and it has to be in the following format '\x02\x81....' this is my code
from binascii import unhexlify
string='0281E1B1'
print unhexlify(string)
gives me some randon symbols ?a+ instead of \x02\x81\xE1\xB1 I have python 2.7 so decode('hex') isnt working either