Last active
August 26, 2020 09:33
-
-
Save zxyle/5b4164c13a18b202d71a6e5405e94176 to your computer and use it in GitHub Desktop.
implement progress bar with Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def show_progress(has, total): | |
rate = float(has) / float(total) | |
rate_num = int(rate * 100) | |
print('\r%s%% %s' % (rate_num, '#' * int(rate_num / 2)), end='') | |
for i in range(1, 101): | |
show_progress(i, 100) | |
import time | |
time.sleep(0.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment