清除IPython中的屏幕 [英] Clearing the screen in IPython
问题描述
IPython中是否有命令清除屏幕?
Is there a command in IPython to clear the screen?
编辑:正如@Saher在下面提到的,我可以使用 import os清理屏幕
; os.system('CLS'),但有没有办法在不必导入所有 os
的情况下执行此操作?
As @Saher mentions below, I can clean the screen using import os; os.system('CLS')
, but is there a way to do this without having to import all of os
?
推荐答案
要清除Windows上的屏幕,请使用!CLS
。
To clear the screen on Windows, use !CLS
.
在类Unix系统上,使用!clear
。
On Unix-like systems, use !clear
.
shell命令由操作系统执行,如果有感叹号。请参见 http://ipython.readthedocs.io/en/ stable / interactive / reference.html#system-shell-access 。
A shell command is executed by the operating system if prepended by an exclamation mark. See http://ipython.readthedocs.io/en/stable/interactive/reference.html#system-shell-access.
请注意,如果命令定义为别名,那么命令也应该没有感叹号。请参见 http://ipython.readthedocs.io/en/stable/interactive /shell.html?#aliases 。
Note that commands should also work without the exclamation mark if they are defined as aliases. See http://ipython.readthedocs.io/en/stable/interactive/shell.html?#aliases.
还有一个用于清除屏幕的 Ctrl + L 快捷方式。请参阅 http://ipython.readthedocs.io/ en / stable / config / shortcuts / index.html#single-filtered-shortcuts 。
There is also a Ctrl+L shortcut for clearing the screen. See http://ipython.readthedocs.io/en/stable/config/shortcuts/index.html#single-filtered-shortcuts.
这篇关于清除IPython中的屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!