Created
February 17, 2023 22:06
-
-
Save brettvitaz/97953b461e18087f1d37598561c36aec to your computer and use it in GitHub Desktop.
Simple console progress bar with no dependencies
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 print_progress_bar(iteration, total, prefix='', suffix='', decimals=1, length=100, fill='█', print_end=""): | |
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total))) | |
filled_length = int(length * iteration // total) | |
bar = fill * filled_length + '-' * (length - filled_length) | |
print(f'\r{prefix} |{bar}| {percent}% {suffix}', end=print_end) | |
# Print New Line on Complete | |
if iteration == total: | |
print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment