1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
def clear_screen_std():
    print("\033c\033[3J\033[2J\033[0m\033[H", end='')

def clear_screen_win():
    os.system('cls')

## Visual Studio Code's Terminal and  Windows Terminal can use clear_screen_std
## Visual Studio Code has COLORTERM=truecolor in enviroment
## Windows Terminal has WT_SESSION=${UUID} in enviroment
CLEAR_MOTHOD = clear_screen_std if os.name != 'nt' or "WT_SESSION" in os.environ or "COLORTERM" in os.environ else clear_screen_win

def clear_screen():
    CLEAR_MOTHOD()