Created
October 12, 2016 07:39
-
-
Save sibosutd/c1d9ef01d38630750a1d1fe05c367eb8 to your computer and use it in GitHub Desktop.
Implementation of python progress bar (or status bar) without using Progressbar library.
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
''' | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice :)