可能的复制品: 蟒蛇中的透明终端 如何清除 Python 解释器控制台
我正在尝试用 Python 编写一个程序,但我不知道如何清除屏幕。 我同时使用 Windows 和 Linux,并使用命令来清除这些操作系统中的屏幕,但我不知道如何在 Python 中做到这一点。
如何使用 Python 清除屏幕?
如果你的意思是屏幕上你有解释器提示 >>>你可以做 CTRL + L对 Bash shell 可以帮助。Windows 没有对等的。你可以的
>>>
import os os.system('cls') # on windows
或者
os.system('clear') # on linux / os x