Skip to content

Instantly share code, notes, and snippets.

@shavit
Created October 25, 2016 17:54
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 shavit/2de2485f86eaa72f989fee4bd63d7b12 to your computer and use it in GitHub Desktop.
Save shavit/2de2485f86eaa72f989fee4bd63d7b12 to your computer and use it in GitHub Desktop.
Print new output on the same line with python 3
#
# Print in one line dynamically
#
from sys import stdout
from time import sleep
def progress():
for i in range(0,100):
stdout.write('\rLoading {}%'.format(i+1))
stdout.flush()
sleep(0.01)
print('\nComplete')
return
if __name__ == '__main__':
progress()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment