With tqdm(unit='B', unit_scale=True, miniters=1,ĭesc=eg_link.split('/')) as t: # all optional kwargs urllib.urlretrieve(., reporthook=reporthook) The tqdm instance once you're done with it (easiest using `with` syntax). Here’s an example with urllib" import urllib I recommend using tqdm - which makes it simple to turn any iterable or process into a progress bar, and handles all messing about with terminals needed.įrom the documentation: "tqdm can easily support callbacks/hooks and manual updates. PrintEnd - Optional : end character (e.g. Length - Optional : character length of bar (Int)įill - Optional : bar fill character (Str) Total - Required : total iterations (Int)ĭecimals - Optional : positive number of decimals in percent complete (Int) # Print iterations progressĭef printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):Ĭall in a loop to create terminal progress - Required : current iteration (Int) Note: All code in this answer was created for Python 3 see end of answer to use this code with Python 2. Here's an aggregate of many of the answers below that I use regularly (no imports required). Python 3 A Simple, Customizable Progress Bar
0 Comments
Leave a Reply. |