The buffering behavior of io operations on files is divided into
Full buffer:Related to the system and disk block size, n bytes after a write operation is performed
Row buffering:Perform a write operation when a newline character is encountered
No buffering:Immediate write operation
open() function
help(open) Help on built-in function open in module io: open(...) open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None) -> file object
where the parameter buffering controls the buffering behavior
buffering defaults to -1, the system's default full buffering
The buffering can be set to any integer greater than 1, and the number of bytes is the full buffering of the buffering
buffering=1, set to line buffering mode
buffering=0, set to unbuffered mode
Above this detailed explanation of the buffering behavior of python file read and write is all that I have shared with you, I hope to give you a reference, and I hope that you will support me more.