0

我对 micropython 有算术问题。

from microbit import *

counter = 0

while True:
    display.show('8')
    if accelerometer.was_gesture('shake'):
        display.clear()
        sleep(1000)
        counter =  counter + 1
        display.scroll(counter)
    sleep(10)

LED 上显示的错误:TypeError: can't convert to int

我在这里想念什么?

4

1 回答 1

1

您可以访问 REPL 吗?我会在 REPL 中单独测试每一行,这样你现在就会知道错误在哪里。

或者删除大部分代码,直到你有一些工作,然后一次添加一行。一旦你有错误的线,它就会更容易解决。

从这个开始:

from microbit import *

counter = 0

while True:
    display.show('8')
    sleep(10)
于 2017-08-02T07:36:37.943 回答