我无法运行此代码:
match shape:
case Point(x, y):
...
case Rectangle(x, y, _, _):
...
print(x, y)
Run Code Online (Sandbox Code Playgroud)
我match在python中找不到关键字,
我在这里找到它:https : //www.python.org/dev/peps/pep-0622/#the-match-statement
...任何的想法??
更新:刚刚看到你的答案,像我这样的新 python 开发人员可能会犯同样的错误,所以我会把这个问题留给可能需要的每个人......谢谢你们,我真的很感谢你们的努力!
python functional-programming python-3.10 structural-pattern-matching