在 BBC microbit 上,我收到此错误,但我不知道为什么:
AttributeError: 'str' object has no attribute 'partition'
运行此代码时:
uart.write('Received: "' + incoming + '"\n')
head, mid, tail = incoming.partition(' ')
传入是一个字符串,可以在控制台中看到
MicroPython v1.9.2-34-gd64154c73 on 2017-09-01; micro:bit v1.0.1 with nRF51822
Type "help()" for more information.
>>>
>>> Received: "buggy direction 2.16 1.2"
Traceback (most recent call last):
File "__main__", line 122, in <module>
File "__main__", line 25, in drive
AttributeError: 'str' object has no attribute 'partition'
有什么想法可以在这里做吗?