Raspberry Pi 2 模型 B 阻止了我的 def 功能

Raspberry Pi 2 Model B is preventing my def function

我有一个 raspberry Pi 2 Model B。我正在尝试编写一个程序,当输入为 'Yes' 时打开 LED。发生的事情是我得到一个语法错误,说 def 是箭头指向 f 的错误。这是我的代码:

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)

GPIO.setwarnings(False)

GPIO.setup(40, GPIO.OUT)

GPIO.setup(38, GPIO.OUT)

GPIO.output(38, 1)

def start():
    main(input("> ")

def main(yn):
    while True:
        if yn == 'Yes':
            GPIO.output(40, 1)
            print("The LED is on!")
            break
        if yn == 'No':
            GPIO.output(40, 0)
            print("The LED is off!")
            break
    start()
start()

请提前帮忙,谢谢!

您的 start 函数缺少右括号:

def start():
    main(input("> "))