S
S
Semyon Beloglazov2017-07-23 19:28:56
Python
Semyon Beloglazov, 2017-07-23 19:28:56

How to output and change string in CMD Python?

It is necessary for some script to make a progress bar.
You can, of course, print a new line each time using print(), but how, for example, can you print and change an already existing line so as not to create a new one? Ps I'm new to python and maybe I still don't understand something, so please don't judge too harshly.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2017-07-23
@Batlab

import time

for i in range(1, 101):
    print('{} {}%'.format('#' * (i // 10), i), end='\r')
    time.sleep(0.1)

Or you can use tqdm .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question