Let's say I have a counter that counts from 0 to 100000. I don't want all the numbers showed, I just want to see the number we are at end the % of completion.
I know that if I want to rewrite over the line, I must add \r at the beginning. However, if I want to do this on two lines, how am I supposed to do that ?
1
0.001%
then
2
0.002%
Also, let's say I want to add new lines for the numbers, but always keep the percentage at the bottom like this:
1
2
3
4
5
6
7
8
0.008%
Do you have any idea on how to achieve that?
Here is my code so far (doesn't work, obviously):
from sys import stdout
for i in range(100000):
stdout.write(str(i) + '\r\n')
stdout.write('%.2f' % (i / 100000 * 100) + '%\r')
stdout.flush()
stdout.write('\n')
Thank you !