I want to add a clear screen function to the standard function list (without importing it) such as print
on python. When I invoke clear
in python it should clear the screen. How can I do it?
import os
def clear():
os.system("clear")
#os.system('echo -ne "\eD\eD\eD\e[A\e[A\e[A"')
Secondly any idea why this is not working os.system('echo -ne "\eD\eD\eD\e[A\e[A\e[A"')
Edit:
Solution for os.system('echo -ne "\eD\eD\eD\e[A\e[A\e[A"')
is print('\x1b[J\x1b[A\x1b[A\x1b[A'*20, end='')
(py3) whole credit to this code goes to @metatoaster