The following are the two top commands to clear the screen in Python. Also shown small video presentation how to use commands.
How to clear screen in Python
Even though, your python is installed on Linux, the “CLEAR” screen will not work in Python.
Clear Screen Command Python 2*
The below are the commands to clear console in Python.
You can always print enough newlines to clear your view of the window:
print "\n" * 80
or use os.system to issue a command the shell/terminal/cmd will understand:
import os os.system("cls")
import os os.system("clear")
Video to Clear Screen in Python 2*
Clear Screen Command Python 3*
In Python 3*, to clear your screen you need special command. The Linux command ‘clear’ or ‘cls’ will not work.
Command to clear Screen -1
>>>print("\n" * 80)
Command to clear Screen -2
>>>import os >>>os.system('clear')