Oct-19-2018, 03:50 PM
I'm trying to write a script to clear and write over the last printed line by following a tutorial.
this is my code
how to fix this error.I need to write over integers 0 to 9
this is my code
import time import sys def delete_last_lines(n=1): for _ in range(n): sys.stdout.write(str(_)) sys.stdout.write("\033[F") #back to previous line sys.stdout.write("\033[K") #clear line time.sleep(1) delete_last_lines(n=10)but it gives out following output
Output:0[F[K1[F[K2[F[K3[F[K4[F[K5[F[K6[F[K7[F[K8[F[K9[F[K
I need to clear the privious line instead of printing [F[K how to fix this error.I need to write over integers 0 to 9