how to clear the screen in python [duplicate]

自古美人都是妖i 提交于 2019-11-26 02:17:25

问题


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.

How do I use Python to clear the screen?


回答1:


If you mean the screen where you have that interpreter prompt >>> you can do CTRL+L on Bash shell can help. Windows does not have equivalent. You can do

import os
os.system('cls')  # on windows

or

os.system('clear')  # on linux / os x


来源:https://stackoverflow.com/questions/4810537/how-to-clear-the-screen-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!