Python 如何在 sublime 文本编辑器中清除控制台
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24755246/
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
How to clear console in sublime text editor
提问by Curious_k.shree
How to clear console in sublime text editor. I have searched on internet too..But can't find proper shortcut for that. Please provide info
如何在 sublime 文本编辑器中清除控制台。我也在互联网上搜索过..但找不到合适的快捷方式。请提供信息
采纳答案by MattDMo
I assume you're talking about the console accessible via View -> Show Console
or Ctrl`. Unlike otheranswerson SO, which deal with clearing the Python console when opened from the command prompt, os.system("cls")
or os.system("clear")
(depending on your OS) don't work with the Sublime console. The Sublime API(version 2 or version 3) does not have any built-in console-clearing method, and I was unable to find any undocumented method in sublime.py
or sublime_plugin.py
. The console appears to be read-only, as selecting all the text and hitting Deletedoesn't work either.
我假设您在谈论可通过View -> Show Console
或访问的控制台Ctrl`。与SO 上的其他答案不同,后者处理从命令提示符打开时清除 Python 控制台,os.system("cls")
或者os.system("clear")
(取决于您的操作系统)不适用于 Sublime 控制台。的崇高API(版本2或第3版)不具有任何内置控制台结算方法,而我无法找到任何无证方法sublime.py
或sublime_plugin.py
。控制台似乎是只读的,因为选择所有文本并点击Delete也不起作用。
I've been looking into this for some time, and I've come to the conclusion that it does not appear to be possible. However, there is a hackish workaround - just run print('\n'*100)
to print 100 newline characters, and you won't be able to see any of the previous output unless you scroll up some distance.
我已经研究了一段时间,我得出的结论是它似乎不可能。但是,有一个骇人听闻的解决方法 - 只需运行print('\n'*100)
以打印 100 个换行符,除非向上滚动一段距离,否则您将无法看到任何先前的输出。
回答by FichteFoll
A new window will always have a clean console. You can use this to open a new window, close the old one and then reopen your project (assuming it is a saved project and not anonymous). This requires the hot_exit
setting to be true, which is the default.
新窗口将始终有一个干净的控制台。您可以使用它打开一个新窗口,关闭旧窗口,然后重新打开您的项目(假设它是一个已保存的项目而不是匿名的)。这要求hot_exit
设置为 true,这是默认值。
回答by yujiezhang
I installed ClearConsole package, then type alt+k to clear then console.
我安装了 ClearConsole 包,然后键入 alt+k 清除然后控制台。