Yonlif Yonlif -4 years ago 52
Python Question

remove the last written line and replace it python

In order to create a progress bar that show the lode by present

The thinking behind it was to erase the line and then rewrite it so it will look like the current precent.

I tried to do this:

import time
---some kind of loop---:
... downloading stuff ...
b = str((prhelp / 576)*100)
print(b + "%", end="\r")
prhelp = prhelp + 1

But it just don't printing any thing

Also I would like to know how to print a number only 3 digits after the dot -

So my program won't print too long precent

Answer Source

At the end I just needed to do:

import time
b = str(round((prhelp / 576) * 100,3))
print('\r',end = "")
print(b + "%",end = "")
prhelp = prhelp + 1

By doing

print('\r',end = "")

I'm removing the last line and makeing place for the next number im writing.

Thanks for all the helpers

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download