Created
May 16, 2021 02:43
-
-
Save fadhilsaheer/3f5fcafafbed0b5432dc6540d5272f22 to your computer and use it in GitHub Desktop.
clear terminal according to os
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import platform | |
import os | |
""" | |
Windows is the only major os to use `cls` to clear terminal and other for sure use `clear` | |
so we could check the platform and execute command accordingly | |
""" | |
def clear(): | |
if platform.system() == "Windows": | |
os.system("cls") | |
else: | |
os.system("clear") | |
clear() # use this function to clear terminal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment