Skip to content

Instantly share code, notes, and snippets.

@fadhilsaheer
Created May 16, 2021 02:43
Show Gist options
  • Save fadhilsaheer/3f5fcafafbed0b5432dc6540d5272f22 to your computer and use it in GitHub Desktop.
Save fadhilsaheer/3f5fcafafbed0b5432dc6540d5272f22 to your computer and use it in GitHub Desktop.
clear terminal according to os
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