如何在python中清除屏幕
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4810537/
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 the screen in python
提问by shiester
Possible Duplicates:
clear terminal in python
How to clear python interpreter console?
I'm trying to write a program in Python but I don't know how to clear the screen. I use both Windows and Linux and I use commands to clear the screen in those, but I don't know how to do it in Python.
我正在尝试用 Python 编写程序,但我不知道如何清除屏幕。我同时使用 Windows 和 Linux,我使用命令清除其中的屏幕,但我不知道如何在 Python 中执行此操作。
How do I use Python to clear the screen?
如何使用 Python 清除屏幕?
回答by Senthil Kumaran
If you mean the screen where you have that interpreter prompt >>>you can do CTRL+Lon Bash shell can help. Windows does not have equivalent. You can do
如果你的意思是你有那个解释器提示的屏幕,你>>>可以在 Bash shell 上做CTRL+L可以提供帮助。Windows 没有等效项。你可以做
import os
os.system('cls') # on windows
or
或者
os.system('clear') # on linux / os x

