Created
April 23, 2019 10:53
-
-
Save patillacode/3a9426fd9b6c580adf760964aec83efd to your computer and use it in GitHub Desktop.
Python loading bar
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
def print_status_bar(number, number_of_pages): | |
percentage = int((number / number_of_pages) * 100) | |
progress = int((percentage * 20) / 100) | |
progress_msg = '#' * progress + '.' * (20 - progress) | |
msg = f' Processing [{progress_msg}] ({number}/{number_of_pages})' | |
print(msg, end='\r', flush=True) | |
# Use | |
number_of_pages = Page.objects.count() | |
for number, page in enumerate(Page.objects.all()): | |
print_status_bar(number, number_of_pages) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment