I have a Python program I am writing and I want it to be able to change text after it is printed. For example, let\'s say I want to print \"hello\" and erase one letter eve
Here's one way to do it.
print 'hello',
sys.stdout.flush()
...
print '\rhell ',
sys.stdout.flush()
...
print '\rhel ',
sys.stdout.flush()
You can probably also get clever with ANSI escapes. Something like
sys.stdout.write('hello')
sys.stdout.flush()
for _ in range(5):
time.sleep(1)
sys.stdout.write('\033[D \033[D')
sys.stdout.flush()