Python: 關於 sys.stdout.flush()


stackoverflow 

https://stackoverflow.com/questions/10019456/usage-of-sys-stdout-flush-method

 

Python's standard out is buffered (meaning that it collects some of the data "written" to standard out before it writes it to the terminal).

Calling sys.stdout.flush() forces it to "flush" the buffer, meaning that it will write everything in the buffer to the terminal, even if normally it would wait before doing so.

Here's some good information about (un)buffered I/O and why it's useful:
https://en.wikipedia.org/wiki/Data_buffer


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM