社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

micropython-SyntaxError中的匹配大小写:无效语法

David • 1 年前 • 775 次点击  

我在我的树莓皮皮上使用python 3.10.5,我正在尝试使用 match & case 而不是 if 语句当我尝试运行程序时,它会返回一个错误:

Traceback (most recent call last):
  File "<stdin>", line 22
SyntaxError: invalid syntax

以下是我的功能:

async def BlueTooth(delay):
    while True:
        if uart.any():
            command = uart.readline()
            #print(command)   # uncomment this line to see the received data
            match command:
                case b'1':
                    led.value(1)
                case b'0':
                    led.value(0)
            write_i2c("cmd: {}\n{}".format(command, Commands.get_command_action(str(command))))

        await asyncio.sleep(delay)

我已经检查过了,一切都应该正常,是什么原因导致了问题?
顺便说一句,我正在使用 Thonny 作为我的编辑。

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/158009
 
775 次点击  
文章 [ 1 ]  |  最新文章 1 年前