Python Clear Console
import sys, os
os.system('cls')
Weeke
import sys, os
os.system('cls')
import os
os.system('cls' if os.name == 'nt' else 'clear')
import os
os.system('clear')
def clear():
# for windows
if name == 'nt':
_ = system('cls')
# for mac and linux(here, os.name is 'posix')
else:
_ = system('clear')
As you mentioned, you can do a system call:
For Windows
>>> import os
>>> clear = lambda: os.system('cls')
>>> clear()
For Linux the lambda becomes
>>> clear = lambda: os.system('clear')