0

So what im trying to do is printing several data with """ """ my Question is if its possible that i can hold this without python printing it again and again im using the sys.stdout.write func with "\r" at the end but in the Console its still moving down. Does Somebody have an idea how to it with """ """ or another method?(Im using Python 2.7)

  • 1
    Does this answer your question? [python print end=' '](https://stackoverflow.com/questions/2456148/python-print-end) – Graeme May 21 '20 at 12:52

2 Answers2

0

In python 2 you can simply add comma to end of the statement to avoid adding "\n" to output.

print "Hello",
print "world",

The output will be Hello world.

Update:

Look here to read about escape codes.

Made a simple example for you:

import time


template = """
Line 1: [%d]
Line 2: [%d]
"""  

prev_line_char = "\033[F"
k = 3
m = 4

while True:
    print template % (k, m)
    k += 1
    m += 3
    time.sleep(1)

    for i in range(4):
        print prev_line_char,
Nestor Yanchuk
  • 1,186
  • 8
  • 10
0

Thats not really what i want i want the stuff thats in the """ """ to be not moving in the console so that its not printed every time again want to stay in one place like this and not like this