The problem of the function of sys.stdout.flush ()

the information found is said to be real-time output display, and there is a sample code

import time
import sys

for i in range(5):
    print(i)
    sys.stdout.flush()
    time.sleep(1)

but I try to annotate him and there is no difference between annotating him and not commenting it. It"s a number per second. I use python3

.
May.08,2021

https://stackoverflow.com/que.

the point is that your situation is normal and this code is useful.
this line of code is mainly to prevent the output to the terminal from being cached by python, but through the environment variable,-u starts python and the running system, it can affect the cache or not. This code ensures that it can output 1 number per second in all places, and after removal, it will be cached in some places.
and your computer just doesn't use caching.
seems to be very little of windows (won't?) Cached occurs.


if you are using PYTHON3, your code should be changed to print (iJournal enduring codes'), then there will be a change

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3bf45-2c2e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3bf45-2c2e0.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?