Skip to content

Instantly share code, notes, and snippets.

@DavidFricker
Created October 1, 2018 11:08
Show Gist options
  • Select an option

  • Save DavidFricker/86914cbaa165d916c648d676d36b77d9 to your computer and use it in GitHub Desktop.

Select an option

Save DavidFricker/86914cbaa165d916c648d676d36b77d9 to your computer and use it in GitHub Desktop.
Displays progress in 1% steps with a big loading bar
import sys
def print_loading_bar(complete, total):
complete_percentage = round((complete/total * 100), 2)
if complete_percentage % 1 == 0:
loading_bar = (['='] * int(complete_percentage)) + (['>']) + (['-'] * (100 - 1 - int(complete_percentage)))
sys.stdout.write("\r" + str(complete_percentage) + "%: "+ ''.join(loading_bar))
sys.stdout.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment