Last active
October 6, 2015 14:28
-
-
Save tai2/3006949 to your computer and use it in GitHub Desktop.
Display progress of work
This file contains hidden or 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 | |
import sys | |
import time | |
if __name__ == '__main__': | |
N = 100 | |
for i in range(N): | |
time.sleep(1) | |
# http://en.wikipedia.org/wiki/ANSI_escape_code | |
print '\033[2K\033[0G%d/%d'%(i + 1, N), # ESC[u means restore current positon then ESC[K erase to the end | |
sys.stdout.flush() | |
print '\ndone' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment