Created
September 2, 2014 22:11
-
-
Save yevrah/38f5d5c546b1753808e7 to your computer and use it in GitHub Desktop.
Printing on the same line
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
#!/usr/bin/env python | |
# encoding: utf-8 | |
# This is an example of how to print a console | |
# message on the same line | |
from time import sleep | |
import sys | |
def ps(string): | |
sys.stdout.write(string) | |
sys.stdout.flush() | |
sleep(0.5) | |
sys.stdout.write("\r") | |
ps("1. 25% Complete") | |
ps("2. 50% Complete") | |
ps("3. 75% Complete") | |
ps("4. 100% Done ") | |
# Clear out of the line | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment