Skip to content

Instantly share code, notes, and snippets.

@sibosutd
Created October 12, 2016 07:39
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save sibosutd/c1d9ef01d38630750a1d1fe05c367eb8 to your computer and use it in GitHub Desktop.
Save sibosutd/c1d9ef01d38630750a1d1fe05c367eb8 to your computer and use it in GitHub Desktop.
Implementation of python progress bar (or status bar) without using Progressbar library.
'''
Implementation of python progress bar (or status bar)
without using Progressbar library.
Result:
Completed: [==================================================] 100%
Created by Sibo, 12 Oct.
'''
import time
import sys
total = 1007 # total number to reach
bar_length = 30 # should be less than 100
for i in range(total+1):
percent = 100.0*i/total
sys.stdout.write('\r')
sys.stdout.write("Completed: [{:{}}] {:>3}%"
.format('='*int(percent/(100.0/bar_length)),
bar_length, int(percent)))
sys.stdout.flush()
time.sleep(0.002)
@MatLumin
Copy link

nice :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment