小编ped*_*tro的帖子

可以在 Google Colab 中使用 Python 3.10 吗?

我想在 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)

有什么办法可以让这个工作吗?

python python-3.x google-colaboratory

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

google-colaboratory ×1

python ×1

python-3.x ×1