python_wiki:clear_screen

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

python_wiki:clear_screen [2016/11/30 22:08]
billdozor
python_wiki:clear_screen [2019/05/25 23:50]
Line 1: Line 1:
-====== 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: 
-<code python> 
-clear_screen() 
-..do other stuff now that my screen is clear! 
-</code> 
- 
----- 
- 
-====== The Code ====== 
- 
-<code python> 
-import sys,subprocess 
- 
-def clear_screen(): 
-  if(sys.platform == "win32"): 
-    subprocess.call("cls", shell=True) 
-  else: 
-    subprocess.call("clear", shell=True) 
-</code> 
- 
----- 
  
  • python_wiki/clear_screen.txt
  • Last modified: 2019/05/25 23:50
  • (external edit)