home / academic notes /
Python cheatsheet
Clearing printed lines in terminal
Repeat the print statement for as many lines as you want to erase.
LINE_UP = '\033[1A'
LINE_CLEAR = '\x1b[2K'
print(LINE_UP, end=LINE_CLEAR)