When you want to count down, use print normally
for i in range(100):
print i
Then on the console
1 2 3 4 5 …
, It will be output vertically. It's hard to see this, so like the progress meter displayed at the time of installation, when you output the next number, the previous output disappears and the next number appears there __.
When overwriting
import sys, time
for num, i in enumerate(range(100)):
sys.stdout.write("\r%d" % num)
sys.stdout.flush()
time.sleep(0.01)
\ r in sys.stdout.write looks like a kid. Without it, it will not be overwritten.
When adding
import sys, time
for i in range(100):
sys.stdout.write("=")
sys.stdout.flush()
time.sleep(0.01)
This will prevent the screen from being filled with useless output.
Recommended Posts