Math TypeError:无法转换为int-Micropython

Math TypeError:无法转换为int-Micropython,math,int,micropython,Math,Int,Micropython,我对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(

我对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:无法转换为int


我在这里遗漏了什么?

您有权访问REPL吗? 我将在REPL中单独测试每一行,这样您就可以知道错误所在

或者,删除大部分代码,直到您有了可以使用的代码,然后一次添加一行。一旦你有了一条带有错误的线,它将更容易解决

从这个开始:

from microbit import *

counter = 0

while True:
    display.show('8')
    sleep(10)
尝试使用display.scrollstrcounter