import serial import string ser = serial.Serial('COM6') # open serial port print(ser.name) # check which port was really used c=raw_input() while(len(c)>0): ser.write(c) c=raw_input() ser.close()