我如何从 Sublime text 3 运行 python?

How do I run python from Sublime text 3?

我刚刚得到 python 和 sublime 3。当我按下 control + b 时,我在控制台中得到了这个:

'python' is not recognized as an internal or external command, operable program or batch file.

它不会 运行 我的神奇代码!

print"Hi"

我确实安装了 Python,我该如何更改 PATH?

如果您安装了 Python 2,您只需继续安装 Python 3,因为它是语言的现在和未来。不要从 2 开始学习 Python,你会养成各种坏习惯。和3一起学习,等你能看懂的时候再回去找出和2的不同点。我假设您使用的是 64 位系统,因为现在一切都是这样,所以请从 here. If you're not, get this one 下载 Python 3。 运行 安装程序,然后选择显示 "Add Python to my PATH" 的选项(我忘记了具体位置)。完成安装,重新启动 Sublime,它应该会正常运行 python.exe

顺便说一句,在 Python 3 中,print 是一个函数,所以您 运行 的第一个代码应该是

print("Hi!")

在构建之前不要忘记保存文件。

哦,是的,避免 "Learn Python the Hard Way" 就像 瘟疫 It sucks. Instead, read the official tutorial first, then pick something here and/or here.