[Tutor] Converting bytes to a string

Phil phillor9 at gmail.com
Sun Apr 18 04:13:47 EDT 2021


I'm reading serial data from a Pi Pico and I notice that there is what 
looks like a small 'd' on the end of the string after decoding the byte.

The data is received as b'26.3\r\n' and to convert it to a string I do 
the following:

s = data.decode()
s.strip('\r\n')              # at this point there is a mystery 
character on the end of the string
print(s.strip())           # this strips off the small 'd'

I'm wondering what the small, unprintable, 'd' is?

-- 

Regards,
Phil



More information about the Tutor mailing list