我想在 Google Colab 中使用 Python 3.10 的结构模式匹配功能,因此使用以下命令
!sudo apt-get install python3.10
!sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.10 1
!sudo update-alternatives --set python3 /usr/bin/python3.10
Run Code Online (Sandbox Code Playgroud)
我能够输出!python --version3.10.0,但print(sys.version)在代码单元格中仍然输出 3.7.12,因此匹配案例语句引发SyntaxError
number = 1
match number:
case 0:
print("Error")
case _:
print(number)
Run Code Online (Sandbox Code Playgroud)
有什么办法可以让这个工作吗?