Skip to content

Instantly share code, notes, and snippets.

@AlgorithmAlchemy
Created June 29, 2023 10:58
Show Gist options
  • Save AlgorithmAlchemy/755546efa213eb0d54b6de8b3d93b019 to your computer and use it in GitHub Desktop.
Save AlgorithmAlchemy/755546efa213eb0d54b6de8b3d93b019 to your computer and use it in GitHub Desktop.
NiceProgressBar_one_string
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