ashutosh_paul
ashutosh_paul

Reputation: 53

Delete a complete line in python 3 output

How can I delete a complete line in the output screen of python?

Can I use the escape sequence '\b' for this?

Upvotes: 0

Views: 45

Answers (1)

Jonathon Reinhart
Jonathon Reinhart

Reputation: 137398

What your asking is somewhat terminal-specific. However, the following solution should work in both Linux and Windows.

  1. Write \r to return to the beginning of the current line.

  2. Write as many spaces as needed to "cover" any previous content on the line.

  3. Write \r to return to the beginning of the current line again.

  4. Write the new text for this line.

Upvotes: 1

Related Questions