Last active
March 22, 2022 22:48
-
-
Save eltrujo/d02cbfd857d6497227fec5e2b381fcd7 to your computer and use it in GitHub Desktop.
Python Progress Bar on Command Window
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
import sys | |
def update_progress(progress, prefix='Progress', suffix=''): | |
bar_len = 60 | |
filled_len = int(round(bar_len * progress)) | |
perc = round(100.0 * progress, 1) | |
bar = '█' * filled_len + '-' * (bar_len - filled_len) | |
ending_char = '\r' if progress != 1 else '\n' | |
sys.stdout.write(f' {prefix} [{bar}] {perc}% {suffix}{ending_char}') | |
sys.stdout.flush() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment