import serial import io ser=serial.Serial('/dev/ttyUSB0',9600,timeout=10) while True: ret=ser.readline() print(ret.decode('ascii').strip()) ser.close()