Created
June 29, 2023 10:58
-
-
Save AlgorithmAlchemy/755546efa213eb0d54b6de8b3d93b019 to your computer and use it in GitHub Desktop.
NiceProgressBar_one_string
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 time | |
def progress_bar(progress, total, bar_length=40): | |
filled_length = int(bar_length * progress // total) | |
bar = '█' * filled_length + '-' * (bar_length - filled_length) | |
percentage = progress / total * 100 | |
print(f'\rProgress: [{bar}] {percentage:.2f}%', end='', flush=True) | |
def simulate_process(total_time): | |
for t in range(total_time + 1): | |
progress_bar(t, total_time) | |
time.sleep(1) | |
total_time = 20 | |
simulate_process(total_time) | |
print() # Добавляем новую строку после завершения прогресса |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment