On 10/6/13 6:47 PM, Robert Jackson wrote:
I am very new to python so I'll apologize up front if this is some boneheaded thing. I am using python and pyserial to talk to an embedded pic processor in a piece of scientific equipment. I sometimes find the when I construct the bytes object to write it adds an extra f to the first byte.

For example if I have b'\x03\x66\x02\x01\xaa\xbb' it evaluates to b'\x03f\x02\x01\xaa\xbb', which doesn't even seem valid.

Can anyone shine some light this?



b'\x66' == b'f' . The hex for "f" is 66. The f isn't inserted, it's the second byte of your string. When Python displays a string, is uses the ASCII character if it can, and a hex escape if it can't. When you use a hex value that is a valid ASCII character, it will display the character.

--Ned.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to