Clear Screen

General Information

A clear screen function that supports Windows, Unix, or Linux CLI programs.


  • import sys : to check for platform
  • import subprocess : to send commands to the OS


Call this function to clear the command line screen:

clear_screen() other stuff now that my screen is clear!

The Code

import sys,subprocess
def clear_screen():
  if(sys.platform == "win32"):"cls", shell=True)
  else:"clear", shell=True)

  • python_wiki/clear_screen.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)