Created
October 25, 2016 17:54
-
-
Save shavit/2de2485f86eaa72f989fee4bd63d7b12 to your computer and use it in GitHub Desktop.
Print new output on the same line with python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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