Sunday, January 15, 2017

How to update a console line without writing a new line in python3


import time
import sys
print('Update the same line in console output')

sys.stdout.write('Doing task a\r')
sys.stdout.flush()
time.sleep(1)
sys.stdout.write('Doing task b\r')
sys.stdout.flush()
time.sleep(1)
sys.stdout.write('Doing task c\n')
time.sleep(1)
print('done')

No comments:

Post a Comment