I tried to update percent on the same line or the same two line by using print
, rather than printing over and over again.
I have already found some approaches for flush output on one line, but no one for multilines.
Below is my code, But they are not working as expected, Could someone help me?
# refresh in one line
for i in range(10):
print("Task A complete %d, Task B complete %d \n" % (i, i), end=" ", flush=True)
# refresh in two line
for j in range(10):
print("Task A complete %d \n" % j, end=" ", flush=True)
print("Task B complete %d \n" % j, end=" ", flush=True)
Thank you all in advance
Update:
with code
# refresh on one line
for i in range(1000000000):
print("Task A complete %d" %i, "Task B complete %d" %i, end='\r', flush=True)
get output like:
Task A complete 994 Task B complete 993
But How can I break this line in two lines like:
Task A complete 994
Task B complete 993