我正在通过串口获取字符串,我正在使用
readport(linker).startswith('STUFF')
如果只有一行,则此方法有效,但当出现多行时,仅当读取的第一行包含该单词时,此方法才有效,即我收到的消息,即:
填充1。。。你知道吗
填充2。。。你知道吗
填充3。。。你知道吗
填充4。。。你知道吗
如果我使用readport(linker).startswith('STUFF4')
,它将返回false,但是如果我使用STUFF1,它将工作。。。你知道吗
它的supose是不同的线在那里或我遗漏了什么。你知道吗
代码是这样的
while state == 2:
print state
time.sleep(0.1)
if readport(linker).startswith('STUFF4') == True:
results.append(readport(linker).rstrip())
state = 3
print results
else:
print results
line = readport(linker).rstrip()
results.append(line)
state = 2
提前谢谢。你知道吗
目前没有回答
相关问题 更多 >
编程相关推荐