The general output to the screen is a set of data at once all show up. This is because the computer in order to improve efficiency, the data will be temporarily put into the cache, and so the cache is full or the end of the operation, and then processing the data once.
A situation like a progress bar requires that a character bounce out one at a time, and flush () is required to enforce this manipulation of the data in the cache.
In class, when the file was flush (), this was finally mentioned. I'll just copy it.
Import sys,timefor i in range: Sys.stdout.write ("#") # call SYS in the screen output Sys.stdout.flush () # Flush (), no this sentence will wait until the cache is full or run to the end to show it all at once. Time.sleep (0.2) # Pause 0.2 and Continue
The effect is that the "#" number on the screen is one of the jumps out.
How Python implements the screen output progress bar