我想在Google中使用Python3.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我能够使!python --version输出3.10.0,但是print(sys.version)仍然在代码单元格中输出3.7.12,因此match cases语句引发SyntaxError
number = 1
match number:
case 0:
print("Error")
case _:
print(number)有什么办法让这件事成功吗?
发布于 2022-10-29 08:19:57
发布于 2022-01-24 14:37:05
您可以尝试以下命令:
!update-alternatives --install /usr/bin/python python /usr/bin/python3.10然后
!update-alternatives --list python这必须显示下载的Python版本。
在那之后,
!sudo update-alternatives --config python
## !Set python3.10 as default.最后,
!sudo update-alternatives --set python /usr/bin/python3.10然后检查colab上的默认Python版本。
!python3 --versionhttps://stackoverflow.com/questions/70141277
复制相似问题