Skip to content

Instantly share code, notes, and snippets.

@qqpann
Created September 18, 2018 17:20
Show Gist options
  • Save qqpann/20d7bcbf9b5aa891738d5c9ae044eaa0 to your computer and use it in GitHub Desktop.
Save qqpann/20d7bcbf9b5aa891738d5c9ae044eaa0 to your computer and use it in GitHub Desktop.
[Python Progress Bar] Python Progress Bar #python #progressbar
import sys
import time
toolbar_width = 40
# setup toolbar
sys.stdout.write("[%s]" % (" " * toolbar_width))
sys.stdout.flush()
# return to start of line, after '['
sys.stdout.write("\b" * (toolbar_width + 1))
for i in range(toolbar_width):
time.sleep(0.1) # do real work here
# update the bar
sys.stdout.write("-")
sys.stdout.flush()
sys.stdout.write("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment