1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] How to refresh the multi-line output dynamically

Discussão em 'Python' iniciado por Stack, Setembro 14, 2024.

  1. Stack

    Stack Membro Participativo

    I want to refresh some info dynamically(just like progress bar), I can do it with following code

    #! /usr/bin/env python
    import sys
    import time

    print "start the output"
    def loop():
    i = 0

    while 1:
    i += 1
    output = "\rFirst_line%s..." % str(i)
    sys.stdout.write(output)
    sys.stdout.flush()
    time.sleep(1)
    loop()


    It could only output single_line info dynamically, When add '\n' into output, It couldn't work as expect.

    output = "\rFirst_line%s...\n" % str(i)


    Any way could help it to refresh multi_line content?

    Continue reading...

Compartilhe esta Página