【发布时间】:2021-02-17 13:02:08
【问题描述】:
我在编写 Raspberry Pi Pico 时遇到问题。我正在使用 Thonny IDE 和 micropython。我只是一个初学者,所以只需从他们的网站 (https://projects.raspberrypi.org/en/projects/getting-started-with-the-pico/6) 下载代码并将其安装到微控制器。但是当我保存这段代码时:
from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_DOWN)
while True:
if button.value():
led.toggle()
time.sleep(0.5)
我收到这条消息:
Traceback(最近一次调用最后一次): 文件“”,第 10 行 IndentationError: unindent 不匹配任何外部缩进级别 你能帮帮我吗?
【问题讨论】:
-
我想知道你是否混合了空格和制表符。您应该始终使用 4 个空格。见这里 - stackoverflow.com/questions/14979224/…
-
您的错误信息提到了第 10 行,但上面显示的只有 8 行
-
我认为你应该在 while 语句后缩进。 PS - Thonny 通常会检测制表符并建议您将它们更改为 4 个空格。
标签: raspberry-pi embedded interpreter micropython thonny