Does any standard "comes with batteries" method exist to clear the terminal screen from a Python script, or do I have to go curses (the libraries, not the words)?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
This will be work in Both version Python2 OR Python3
python -c "from os import system; system('clear')"
A simple and cross-platform solution would be to use either the
cls
command on Windows, orclear
on Unix systems. Used withos.system
, this makes a nice one-liner:You could tear through the terminfo database, but the functions for doing so are in
curses
anyway.For Windows, on the interpreter command line only (not the GUI)! Simply type: (Remember to use proper indentation with python):
Every time you type
clear()
on the shell (command line), it will clear the screen on your shell. If you exit the shell, then you must redo the above to do it again as you open a new Python (command line) shell.Note: Does not matter what version of Python you are using, explicitly (2.5, 2.7, 3.3 & 3.4).
Came across this some time ago
Then just use clearscreen()