user34614: 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!

user35550: 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?


34614: <p>I use this small program on my Raspberry Pi to recieve a string sent by my arduino. </p>

<pre><code>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)
</code></pre>

<p>the code on the arduino is rather simple:</p>

<pre><code>void setup(){
Serial.begin(9600);
}

void loop(){
Serial.println(“Hello Pi”);
delay(2000);
</code></pre>

<p>the annoying part is. I recieve this: </p>

<blockquote>
  <p>b'Hello Pi\r\n' </p>
</blockquote>

<p>instead of the clean</p>

<blockquote>
  <p>Hello Pi</p>
</blockquote>

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

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

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

<p>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:</p>

<pre><code>import serial

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

<p>See also:</p>

<ul>
<li><a href="https://stackoverflow.com/questions/6269765/what-does-the-b-character-do-in-front-of-a-string-literal">What does the 'b' character do in front of a string literal?</a></li>
</ul>
