Skip to content

Instantly share code, notes, and snippets.

@yulkang
Created March 18, 2020 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yulkang/40168c7729a7a7b96d0116d8b1bc26df to your computer and use it in GitHub Desktop.
Save yulkang/40168c7729a7a7b96d0116d8b1bc26df to your computer and use it in GitHub Desktop.
Writing output on the same line multiple times in the console
# On PyCharm Debugger console, \r needs to come before the text.
# Otherwise, the text may not appear at all, or appear inconsistently.
# tested on PyCharm 2019.3, Python 3.6
# Modification of https://stackoverflow.com/a/517523/2565317
import time
print('Start.')
for i in range(100):
time.sleep(0.02)
print('\rDownloading File FooFile.txt [%d%%]'%i, end="")
print('\nDone.')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment