This gist remixes this answer on StackOverflow. My changes:
- I changes the symbol from
#to a unicode character that fills a whole character space -█. - I added a
%symbol after the numbers
This gist remixes this answer on StackOverflow. My changes:
# to a unicode character that fills a whole character space - █.% symbol after the numbers| def progressbar(it, prefix="", size=60, file=sys.stdout): | |
| count = len(it) | |
| def show(j): | |
| x = int(size*j/count) | |
| file.write("{}[{}{}] {}%/{}%\r".format(prefix, "█"*x, "."*(size-x), j, count)) | |
| file.flush() | |
| show(0) | |
| for i, item in enumerate(it): | |
| yield item | |
| show(i+1) | |
| file.write("\n") | |
| file.flush() |
I made a version that allows you to specify the symbols and empty space: