Python 3 – How to delete previous line?

Home » Programming & Design » Python 3 – How to delete previous line?
Programming & Design No Comments

The question says it all, but basically I would like to replace the previous line with as little hassle as possible
Thanks in advance

Other answer:

Donald Trump:
No, the question does NOT say it all – it's incredibly vague.

Tell us EXACTLY what you're trying to do. Are you talking about editing a source listing? Drawing a line on the screen? Altering a text file from a running program? Text output during a program?

efflandt:
You can use ANSI escape sequences for a *nix like terminal (Linux, etc.). They begin with Esc character code beginning with backslash (\033) a left bracket ( [ ) and then the ANSI code. You may need to do something different for Windows.

#!/usr/bin/python
from time import sleep
print("Demo how to cursor up and erase line:")
print("Hello World")
sleep(5)
print("\033[1A\033[0JBye!")

ANSI escape code wiki https://en.wikipedia.org/wiki/ANSI_escap…
Example: https://rosettacode.org/wiki/Terminal_co…

vote_libertarian_in_2008:
You need to be far more specific. Perhaps add some pseudo code so that us programmers can see what you're trying to do.
Zxzxzfwhisaowieir:
Yew

LEAVE A COMMENT