3
在python 3中,我导入了pySerial库,所以我可以通过串行命令与我的arduino uno进行通信,它在python 2.7中工作得很好,但是在python 3中我保留运行到它说这个错误TypeError:unicode字符串不支持,请编码为字节:'allon'在python 2.7我唯一不同的是使用raw_input,但我不知道python 3在这里发生了什么是我的代码python3 pySerial TypeError:不支持unicode字符串,请编码为字节:
import serial, time
import tkinter
import os
def serialcmdw():
os.system('clear')
serialcmd = input("serial command: ")
ser.write (serialcmd)
serialcmdw()
ser = serial.Serial()
os.system('clear')
ser.port = "/dev/cu.usbmodem4321"
ser.baudrate = 9600
ser.open()
time.sleep(1)
serialcmdw()
非常感谢你, –