This is an old revision of the document!
Clear Screen
General Information
A clear screen function that supports Windows, Unix, or Linux CLI programs.
Checklist
- import sys : to check for platform
- import subprocess : to send commands to the OS
Usage
Call this function to clear the command line screen:
clear_screen() ..do other stuff now that my screen is clear!
The Code
import sys,subprocess def clear_screen(): if(sys.platform == "win32"): subprocess.call("cls", shell=True) else: subprocess.call("clear", shell=True)