我们如何在 Atom 编辑器中 运行 一个 Python 脚本?

How do we run a Python script in Atom editor?

我们如何在 Atom 编辑器中 运行 编写 Python 脚本?请看下面有错误的截图: Below I was testing if i can run python in Atom editor. I have also ran the (c:\Anaconda3\Scripts\activate base)command in Anaconda prompt

在您的 Atom 内置终端中,您首先输入不带任何文件参数的“python”,这样您就会进入 Python 交互式提示,包括您的文件名(num.py).

你得到的 SyntaxError 是因为你试图 运行 "python num.py" 作为代码而不是 CMD 命令。

除了@HarryKearney 的回答之外,还有许多软件包可以轻松 运行 脚本。例如,run-in-terminal allows you to press F5 to open a terminal or command prompt window running the python script. Some other options to do similar things are: atom-python-run, atom-runner, script to run code directly in atom and several others you can find in the package repository。如果您经常 运行 宁 python 脚本,选择其中之一并安装它可能会很容易。