python microbit typeerror_TypeError:无法转换为int - Micropython(TypeError: can't convert to int - Micropy...

TypeError:无法转换为int - Micropython(TypeError: can't convert to 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(10)

LED上显示错误:TypeError:无法转换为int

我在这里想念的是什么?

I have arithmetic issues with 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)

Error displayed on the LEDs: TypeError: can't convert to int

What am I missing here?

原文:https://stackoverflow.com/questions/43645438

2020-02-25 15:21

满意答案

你有权访问REPL吗? 我会在REPL中自己测试每一行,这样你现在就会出现错误。

或者删除大部分代码,直到你有一些有用的东西,并一次添加一行。 一旦你有错误的行,它将更容易解决。

从这开始:

from microbit import *

counter = 0

while True:

display.show('8')

sleep(10)

Do you have access to the REPL? I would test every line on its own in REPL, this way you will now where the error is.

Alternatively delete most of the code until you have something that works, and add one line at a time. Once you have the line with the error it will be much easier to sol

你可能感兴趣的:(python,microbit,typeerror)