python和升华文本2出现奇怪错误
我正试图用Python编写一个代码,从蓝牙读取数据。这是我目前的代码:python和升华文本2出现奇怪错误,python,bluetooth,sublimetext2,Python,Bluetooth,Sublimetext2,我正试图用Python编写一个代码,从蓝牙读取数据。这是我目前的代码: import serial arduinoData = serial.Serial('com7', 9600) while True: while(arduinoData.inWaiting() == 0): # Si no hay datos, se espera print "There is no data" pass arduinoString = arduinoData.readli
import serial
arduinoData = serial.Serial('com7', 9600)
while True:
while(arduinoData.inWaiting() == 0): # Si no hay datos, se espera
print "There is no data"
pass
arduinoString = arduinoData.readline()
print "This is the Data: "
print arduinoString
在第一次尝试中,我遇到了以下错误:
所以我搜索了这个错误,发现了这个:
按照答案说的做了之后,这次我得到了:
这是什么意思?这是解码错误还是另一种错误
希望您能帮助我。
[SOH]
是Sublime用于ASCII 0x01(控制字符)的文本表示。您的代码没有问题-这只是通过连接发送的内容。谢谢您的回答。有没有办法翻译这些字符?@PabloFlores把它们翻译成什么?您正试图打印一个字节流以进行输出,因此您可能希望首先对其调用str()
,在这种情况下,您将得到大量的\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01\x01
重复。