Print a progress in Python


Here is how to do this:

import sys

sys.stdout.write("\r%d" % i)
sys.stdout.flush()

Writing '\r' will move the cursor back to the beginning of the line.

If we want to print a %, we need to print an additional % like the folllowing:

sys.stdout.write("\r%d%%" % i)

Comments

Popular posts from this blog

Run tasks in background in Spring

Conditional field inclusion in Jackson and Spring Boot

How to configure Wildfly 10 to use MySQL