Skip to content

Instantly share code, notes, and snippets.

@zxyle
Last active August 26, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zxyle/5b4164c13a18b202d71a6e5405e94176 to your computer and use it in GitHub Desktop.
Save zxyle/5b4164c13a18b202d71a6e5405e94176 to your computer and use it in GitHub Desktop.
implement progress bar with Python
def show_progress(has, total):
rate = float(has) / float(total)
rate_num = int(rate * 100)
print('\r%s%% %s' % (rate_num, '#' * int(rate_num / 2)), end='')
for i in range(1, 101):
show_progress(i, 100)
import time
time.sleep(0.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment