IPython 中有清除屏幕的命令吗?
编辑:正如@Saher 下面提到的,我可以clean the screen使用导入操作系统; os.system('CLS')
,但是有没有办法做到这一点而不必导入所有的os
?
最佳答案
要在 Windows 上清除屏幕,请使用 !CLS
。
在类 Unix 系统上,使用 !clear
。
如果前面有感叹号,则操作系统会执行 shell 命令。见 http://ipython.readthedocs.io/en/stable/interactive/reference.html#system-shell-access .
请注意,如果命令被定义为别名,它们也应该在没有感叹号的情况下工作。见 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 .
关于python - 在 IPython 中清除屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6892191/