Created
August 16, 2018 12:01
-
-
Save insaneyilin/42f659525b325fa1f4bf7649ebec3f1c to your computer and use it in GitHub Desktop.
simple python progress bar
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 progress(count, total, status=''): | |
bar_len = 60 | |
filled_len = int(round(bar_len * count / float(total))) | |
percents = round(100.0 * count / float(total), 1) | |
bar = '=' * filled_len + '>' + '-' * (bar_len - filled_len) | |
if count < total: | |
sys.stdout.write('[%s] %s%s ...%s\r' % (bar, percents, '%', status)) | |
else: | |
sys.stdout.write('[%s] %s%s ...%s\n' % (bar, percents, '%', status)) | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment