import serial ser = serial.Serial('COM3', 9600) ser.flushInput()
from serial import Serial with Serial('/dev/tty.usbserial', 115200) as ser: ser.flushInput()This example uses a `with` statement to create a serial object for a USB port with a baud rate of 115200. The `flushInput()` method is called to clear the input buffer before reading new data. The package/library used in these examples is the Python serial library.