匹配案例 - Spyder无效语法
在Windows 10上,我在虚拟环境中使用Spyder 5.3.1和Python 3.10.4。 我知道,使用Python 3.10出现Match
语句。
但是,每当我在脚本内使用匹配
关键字时,出现以下错误:
Code Analysis
Invalid syntax (pyflakes E)
但是我可以正确运行脚本而不会出现任何问题。 那么这里有什么问题呢?
此外,如果我直接在iPython控制台中尝试,则立即识别Match
关键字。
I am using Spyder 5.3.1 and Python 3.10.4 within a virtual environment, on Windows 10.
I know that with Python 3.10 came the match
statement.
However, whenever I use the match
keyword inside a script, the following error appears:
Code Analysis
Invalid syntax (pyflakes E)
But I can run the script correctly without any problem.
So what can be the issue here?
Moreover, if I try directly in the IPython console, the match
keyword is immediately recognized.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Spyder并不是一个问题,而是它用于覆盖代码的Pyflakes系统。
匹配
是Python 3.10中的新(软)关键字。 pyflakes 2.4.0 目前仅支持Python 3.8。pyflakes 2.5.0 尚未出现,但会掩盖到Python 3.11,并且应该正确地贴上新的
匹配
关键字。It's not so much an issue with Spyder as it is with the Pyflakes system it uses for linting code.
match
is a new (soft) keyword in Python 3.10. Pyflakes 2.4.0 only supports up to Python 3.8 currently.Pyflakes 2.5.0 is not out yet, but will cover up to Python 3.11, and should lint the new
match
keyword properly.“匹配”之后,通过添加此评论来解决“无效的语法错误”
由于这仍然是一个问题,请注意,通过在Github上指出 : https://github.com/spyder-com/spyder-ide/spyder/spyder/spyder/sspyder/17436#issuecomment-10598067055
Since this still is an issue, note that there is a workaround to get rid of the "invalid syntax error" by adding this comment after the "match"
Was pointed out on Github here: https://github.com/spyder-ide/spyder/issues/17436#issuecomment-1059806705