import serial
Serial = serial.Serial('COM3', 38400, timeout=0.5)
if Serial.isOpen():
print("serial open success")
for i in range(10):
Serial.write("iSM".encode("utf-8"))
import time
time.sleep(1.5)
data =Serial.read_all()
print(data) # str
else:
print("serial open failed")
运行截图