Skip to content

Instantly share code, notes, and snippets.

@insaneyilin
Created August 16, 2018 12:01
Show Gist options
  • Save insaneyilin/42f659525b325fa1f4bf7649ebec3f1c to your computer and use it in GitHub Desktop.
Save insaneyilin/42f659525b325fa1f4bf7649ebec3f1c to your computer and use it in GitHub Desktop.
simple python progress bar
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