Python Print Newline Drama

When using the following:

def processSerialData():
    line = ser.readline()
    if len(line) > 2:
        print line

You’ll notice that the output will automatically append an additional newline sequence ‘/n/r’

If you change

print line


print line,

(notice the comma following the variable line) you will keep the interpreter from adding the additional newline.

Leave a Reply

Your email address will not be published. Required fields are marked *