I have a python program with which I have to update the last line of a terminal while on the rest of them I print data as if the last line is non-existent. Here's an example. Suppose we have this (pseudo)code:
1. print("test1")
2. updateLastLine("79 percent")
3. print("test2")
4. updateLastLine("80 percent")
wheres on the terminal the data would look like:
the first 2 lines of code:
test1
79 percent
the next 2 lines of code added:
test1
test2
80 percent
How do I implement such a solution in python? Also, how would I capture input from keyboard from the updating line? It may help to know that the only place I capture input is from the updating line. Is there any library to do this?
A close example would be the sudo apt-get update
command which behaves similarly.