[Python] print(flush = True) function return confused output in jupyter notebook

Discussão em 'Python' iniciado por Stack, Março 6, 2025.

  1. Stack

    Stack Membro Participativo

    My string list is ['I',"'m using",'.\n\nI should',' explain',' that']. I run this command in my Jupyter-lab notebook(Version 4.3.4):

    for c in string:
    print(c, end = '',flush = True)


    Output is:

    I'm using.

    explain that


    enter image description here

    You can see "\n" is black marked. But python3 compiler (Version 3.10.12) return the right output. When I use a different Jupyter-lab kernel it also works well. enter image description here

    I think this might be due to Jupyter-lab. So how to fix it and get the same output? Thanks!

    I view some document about jupyter-lab. I am sure that there no typos.

    Continue reading...

Compartilhe esta Página