Does Python delay print command execution?

In some part of my python program, I need to do this -

  • print a message on the terminal (using the print command)
  • create multiple directories (using os.mkdirs)
  • copy file (using shutil.copy2)
  • Display the message on the terminal again (using the print command)

(All this in a loop)

Now the problem is that the command '1.' runs to "2.", '3.' and "4.", the message of the command "1" is actually displayed. on the screen after completing all 4 commands (together with the message "4."). I want it to display the command message "1". first, then start with the rest of the code ... How can I do this? (Is there something like flushing for the print command?)

+4
source share
1 answer

This may be what you are looking for. How to clear Python print output?

+5
source

Source: https://habr.com/ru/post/1335650/


All Articles