Reputation: 1
Printing text that updates, for example a clock, in python. Ive read some threads about this but they only worked if the program prints out one line. What i am trying to do is, i already have a sort of terminal in python that accepts commands and executes them, it runs in a while loop, now if i wanted to make a clock in the top right corner of the terminal, but preserve what the user is typing and the output of previous commands, how would i do that?
P.S.: Sorry for bad formatting, in typing this from my phone
Upvotes: 0
Views: 473
Reputation: 252
You can easily update stdout with this:
print('foo', end='')
print('\rbar', end='', flush=True)
This example prints out foo
and then changes the line to bar
Upvotes: 1