Created
December 31, 2016 05:10
-
-
Save ravishchawla/1bdcc94a063419e09ba8636660b574ce to your computer and use it in GitHub Desktop.
A python function that can be used to print an ongoing progress bar.
This file contains hidden or 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
import sys; | |
def print_progess(currentProgress, maxProgress, numberDashes, message = ""): | |
progress = numberDashes * (currentProgress / maxProgress) + 1; | |
dashes = "=" * int(progress) + "> " | |
percentage = int(100 * currentProgress / maxProgress) + 1; | |
if percentage > 100: | |
percentage = 100; | |
sys.stdout.write("\r " + "<" + message + "> " + dashes + "{0:.2f}".format(percentage) + "%"); | |
sys.stdout.flush(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment