#!/usr/bin/env python # Print iterations progress def printProgressBar (iteration:int, total:int, prefix:str = '', suffix:str = '', decimals:int = 1, length:int = 100, fill:str = '█', printEnd:str = "\r"): """Print iterations progress. Call in a loop to create terminal progress bar. - current iteration - total iterations - prefix string - suffix string - positive number of decimals in percent complete - character length of bar - bar fill character - end character (e.g. "\r", "\r\n") """ percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total))) filledLength = int(length * iteration // total) bar = fill * filledLength + '-' * (length - filledLength) print(f'\r{prefix} |{bar}| {percent}% {suffix}', end = printEnd) # Print New Line on Complete if iteration == total: print()