在 Sublime 文本中显示 Python 输出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20832826/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Display Python Output in Sublime text
提问by user3144985
New to Python & Sublime
Python 和 Sublime 的新手
Problem: I type 'print ("Hello world")
问题:我输入 'print ("Hello world")
How do I get it to show me the output (Hello world), is it in a separate window? or...
我如何让它向我显示输出(Hello world),它是否在单独的窗口中?或者...
I understand I can use the Python Console built in, but that's a command line, what about when I get to use a ton of code, how do I get the output?
我知道我可以使用内置的 Python 控制台,但这是一个命令行,当我使用大量代码时,如何获得输出?
回答by cronburg
Press CtrlB
按 CtrlB
Alternatively, if you're on linux or mac, save the file as hello.py in your home directory and do the following in a terminal / command line:
或者,如果您使用的是 linux 或 mac,请将文件另存为您的主目录中的 hello.py 并在终端/命令行中执行以下操作:
$ cat hello.py
print("Hello World")
$ python3 hello.py
Hello World
If you're on Windows you're best off using the built-in functionality of sublime.
如果您使用的是 Windows,则最好使用 sublime 的内置功能。
回答by Veedrac
My Sublime Extrasextension, and MiniPy, the extension I stole it from, both allow this. Search "eval" on the Extras Github page or use MiniPy.
我的Sublime Extras扩展和MiniPy(我从它偷来的扩展)都允许这样做。在 Extras Github 页面上搜索“eval”或使用 MiniPy。
Maybe SublimeREPL, too, depending in what you are after.
也可能是SublimeREPL,这取决于您的追求。
回答by user235913
Click on tools > build systems > select Python, then Build with using ctr+shif B and select python, and it ll work. Second time you can use the build command, ctr + B since python is now set as default
单击工具 > 构建系统 > 选择 Python,然后使用 ctr+shif B 构建并选择 python,它会工作。第二次你可以使用构建命令 ctr + B 因为 python 现在被设置为默认值

