Differences
This shows you the differences between two versions of the page.
python_wiki:clear_screen [2015/03/09 23:24] 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 | ||
- | |||
- | ---- | ||
- | |||
- | ===== The Code ===== | ||
- | |||
- | <code python> | ||
- | import sys, | ||
- | |||
- | def clear_screen(): | ||
- | if(sys.platform == " | ||
- | subprocess.call(" | ||
- | else: | ||
- | subprocess.call(" | ||
- | </ | ||
- | |||
- | ==== Usage ==== | ||
- | |||
- | Call this function to clear the command line screen: | ||
- | <code python> | ||
- | clear_screen() | ||
- | ..do other stuff now that my screen is clear! | ||
- | </ |