Clear terminal in Python
Clear terminal in Python
A simple and cross-platform solution would be to use either the cls
command on Windows, or clear
on Unix systems. Used with os.system
, this makes a nice one-liner:
import os
os.system(cls if os.name == nt else clear)
What about escape sequences?
print(chr(27) + [2J)
Clear terminal in Python
Why hasnt anyone talked about just simply doing Ctrl+L in Windows or Cmd+L in Mac.
Surely the simplest way of clearing screen.