Code: Select all
import time
import sys
def loading_bar(count, total, suffix=''):
length = 60
endlength = int(round(length * count / float(total)))
percents = round(100.0 * count / float(total), 1)
bar = '=' * endlength + '-' * (length - endlength)
sys.stdout.write(f'[{bar}] {percents}% ...{suffix}\r')
sys.stdout.flush()
def loading():
items = list(range(0, 200))
total_items = len(items)
print("Loading:")
for i, item in enumerate(items):
time.sleep(0.1)
loading_bar(i + 1, total_items, suffix=str(item))
print()
print("Done!")
time.sleep(1)
loading()