I've tried many ways to clear python interpreter screen like:
import os
os.system("cls")
but couldn't do so, please tell me how to do it.
I've tried many ways to clear python interpreter screen like:
import os
os.system("cls")
but couldn't do so, please tell me how to do it.
>>> import os
>>> os.system("cls")
Should work on windows.
If you are using Linux, you might use clear
instead of cls
.
os.system("cls")
will work only on windows machine. If you are UNIX user, do:
Using escape sequence:
print(chr(27) + "[2J")
Alternatively, if you are Unix user (not Windows), you may also do:
import sys
sys.stderr.write("\x1b[2J\x1b[H")
# Code for clear screen in UNIX machines