Create visual uploads in python

0

Like this:

| ----- |     90%

Where it loads in the seconds I specify. Only for visual use, because I want to make an aesthetic effect only:)

Where the lines are the ends of the loading bar and the hyphens progress, where I want to display the completion percentage below

    
asked by anonymous 10.06.2017 / 16:30

1 answer

0

I used the '#' character instead of '-' which is the default, code below, run a console to see the result, adapt the test() function to its context.

import time

def progress_bar(done):
    print("\rProgress: [{0:50s}] {1:.1f}%".format('#' * int(done * 50), done * 100),end='')

def test():
    for n in range(101):
        progress_bar(n/100)
        time.sleep(1)


test()      
Progress: [####################                             ] 20.0%
    
10.06.2017 / 17:15