python3利用pyserial读取arduino串口数据

先安装pyserial
http://pyserial.sourceforge.net/
import time
import serial

ser = serial.Serial( #下面这些参数根据情况修改
port='COM3',
baudrate=9600,
parity=serial.PARITY_ODD,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.SEVENBITS
)
data = ''

while True:
data = ser.readline()
print(data)

已邀请:

要回复问题请先登录注册