serial data gets spoiled I use this small program on my Raspberry Pi to recieve a string sent by my arduino. 

import time
import serial

ser = serial.Serial('/dev/ttyACM0', 9600)

def check_for_command():
    bytestoread = ser.inWaiting()
    if bytestoread != 0:
        temp = ser.read(bytestoread)
        print(temp)

while 1:
    check_for_command()
    time.sleep(0.1)


the code on the arduino is rather simple:

void setup(){
Serial.begin(9600);
}

void loop(){
Serial.println(“Hello Pi”);
delay(2000);


the annoying part is. I recieve this: 


  b'Hello Pi\r\n' 


instead of the clean


  Hello Pi


How do I get rid of those extra bits without using a list for each character.

Thank in advance!
The b prefix in Python 3 just means that it is a bytes literal. It's not part of the output, that's just telling you the type.

The \r\n is a common Carriage-Return and Newline line-ending characters. You can remove that from your string by calling strip().

Since these are floating-point numbers being returned, I'm guessing you're going to want to use them in some way after they are read, too:

import serial

ser = serial.Serial('/dev/ttyACM0', 9600)
while True:
   value = float(ser.readline().strip())
   print('New value is {0:0.2f}'.format(value))


See also:


What does the 'b' character do in front of a string literal?