0
我正在通過Python從Arduino傳感器的串行端口讀取值。奇怪的輸出值:b'[value] r n' - Python串行讀取
我的代碼(蟒蛇):
arduino = serial.Serial(2, 9600, timeout=1)
print("Message from arduino: ")
while True:
msg = arduino.readline()
print(msg)
我不知道爲什麼輸出結果是一樣的東西b'[sensor-value]\r\n'
。 因此,我得到類似b'758\r\n'
b'534\r\n'
b'845\r\n'
等(關於傳感器更改值)。
我該如何轉換?
現在,它的工作!太感謝了!我知道這很簡單,但我甚至不知道如何尋找解決方案。 –