在 CentOS 上安装 Python 后,您可以通过以下步骤启动 Python:
打开终端(Terminal):点击左下角的活动按钮,然后输入 “Terminal” 并按 Enter 键。
在终端中,输入 python 或 python3(取决于您安装的 Python 版本),然后按 Enter 键。这将启动 Python 交互式解释器。
例如:
$ python
Python 2.7.5 (default, Jun 4 2019, 01:26:55)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
现在您已经进入了 Python 交互式解释器,可以开始输入 Python 代码并立即查看结果。要退出 Python 交互式解释器,请输入 exit() 或按 Ctrl + Z 然后按 Enter 键。
如果您想要运行一个 Python 脚本,可以在终端中使用以下命令:
$ python script.py
或者,对于 Python 3:
$ python3 script.py
将 “script.py” 替换为您要运行的 Python 脚本的文件名。