Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

write console output in same place

The simplest way, if you only ever need to update a single line (for instance, creating a progress bar), is to use '
' (carriage return) and sys.stdout:

import sys
import time

for i in range(10):
    sys.stdout.write("
{0}>".format("="*i))
    sys.stdout.flush()
    time.sleep(0.5)
If you need a proper console UI that support moving the pointer etc., use the curses module from the standard library
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #write #console #output #place
ADD COMMENT
Topic
Name
8+9 =