Asked By – scottm
I am new to python and am writing some scripts to automate downloading files from FTP servers, etc. I want to show the progress of the download, but I want it to stay in the same position, such as:
Downloading File FooFile.txt [47%]
I’m trying to avoid something like this:
Downloading File FooFile.txt [47%] Downloading File FooFile.txt [48%] Downloading File FooFile.txt [49%]
How should I go about doing this?
Duplicate: How can I print over the current line in a command line application?
Now we will see solution for issue: How do I write output in same place on the console?
You can also use the carriage return:
sys.stdout.write("Download progress: %d%% \r" % (progress) ) sys.stdout.flush()
This question is answered By – codelogic
This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0