Thursday 15 March 2012

replace - Replacing more than one line in the console in python -


I am writing a program in Python and I want to replace more than one line in the console with the new text. For example, if I have 3 sentences printed in the console:

  print ("Hello World!") Print ("How are you!") Print (" What's happening? ")  

Where each is on a separate row (and it is such as \ n )

How do I change this text when it is displayed in the console? I can not do \ r in this situation due to \ n .

An easy fix would be to simply change the end separator for printing your wire. You can specify that you print the print function end argument

  print ("Hello world!", End = "") print ("\" Rhello world again ! ")  

In this case, we are setting the separator to" "which is nothing, so printing the next strings starts on the same line, thus \ R can be used. On a line.


No comments:

Post a Comment