python_wiki:clear_screen

This is an old revision of the document!


Clear Screen

A clear screen function that uses:

  • sys : to check for platform
  • subprocess : to send commands to the OS
import sys,subprocess
 
def clear_screen():
  if(sys.platform == "win32"):
    subprocess.call("cls", shell=True)
  else:
    subprocess.call("clear", shell=True)

Call this function to clear the command line screen:

clear_screen()
..do other stuff now that my screen is clear!
  • python_wiki/clear_screen.1416886970.txt.gz
  • Last modified: 2019/05/25 23:50
  • (external edit)