Strange extra f added to bytes object
MRAB
python at mrabarnett.plus.com
Sun Oct 6 20:38:15 EDT 2013
On 06/10/2013 23:47, 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'
True
Python always prints a bytestring the same way. It doesn't 'remember'
how it was originally created.
Another example:
>>> b'\x68\x65\x6c\x6c\x6f\x20\x77\x6f\x72\x6c\x64'
b'hello world'
More information about the Python-list
mailing list